feat(controller-peers-env-fallback): add the shared "which candidate is me" lookup (task 1.2)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7328b06c53
commit
d4858e1fe9
4 changed files with 131 additions and 1 deletions
|
|
@ -148,6 +148,21 @@ int xce_parse_peers(const char* peers_str, xce_cluster_config_t* cfg);
|
|||
*/
|
||||
const char* xce_controller_peers_env(void);
|
||||
|
||||
/**
|
||||
* xce_peers_find_identity() — the one "which candidate is me" rule.
|
||||
*
|
||||
* A candidate's key is its name when non-empty, otherwise its hostname
|
||||
* (a named candidate is never matched by its hostname). The first
|
||||
* candidate whose key matches name (compared over XCE_MAXNAME_LEN - 1
|
||||
* characters) wins. An empty name is compared like any other, so it
|
||||
* matches an unnamed candidate with an empty hostname.
|
||||
*
|
||||
* Returns the matching candidate's index, or -1 when cfg or name is NULL
|
||||
* or nothing matches. No default is applied; each caller keeps its own
|
||||
* no-match handling.
|
||||
*/
|
||||
int xce_peers_find_identity(const xce_cluster_config_t* cfg, const char* name);
|
||||
|
||||
/* Test seam: set to non-NULL to override the real connect (unit tests only) */
|
||||
typedef void* (*xce_connect_fn_t)(const char* host, int port);
|
||||
void xce_cluster_set_connect_fn(xce_connect_fn_t fn);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue