feat: support name=host:port format in controller --peers
- xce_candidate_t gains name[] field for logical peer identity - parse_peers stores name prefix before '=' (empty when omitted) - cluster_init matches own identity by name first, hostname as fallback enabling multiple controllers on the same dev host via --peers ctrl-1=10.0.1.1:7000,ctrl-2=10.0.1.2:7001
This commit is contained in:
parent
59597e105e
commit
a05c9bd344
3 changed files with 23 additions and 8 deletions
|
|
@ -60,10 +60,17 @@ static int parse_peers(const char* peers_str, xce_cluster_config_t* cfg)
|
|||
if (!colon)
|
||||
return -1;
|
||||
*colon = '\0';
|
||||
strncpy(cfg->candidates[cfg->candidates_count].hostname, addr,
|
||||
XCE_MAXHOSTNAME_LEN - 1);
|
||||
cfg->candidates[cfg->candidates_count].hostname[XCE_MAXHOSTNAME_LEN - 1] = '\0';
|
||||
cfg->candidates[cfg->candidates_count].port = atoi(colon + 1);
|
||||
xce_candidate_t* cand = &cfg->candidates[cfg->candidates_count];
|
||||
if (eq) {
|
||||
*eq = '\0';
|
||||
strncpy(cand->name, tok, XCE_MAXNAME_LEN - 1);
|
||||
cand->name[XCE_MAXNAME_LEN - 1] = '\0';
|
||||
} else {
|
||||
cand->name[0] = '\0';
|
||||
}
|
||||
strncpy(cand->hostname, addr, XCE_MAXHOSTNAME_LEN - 1);
|
||||
cand->hostname[XCE_MAXHOSTNAME_LEN - 1] = '\0';
|
||||
cand->port = atoi(colon + 1);
|
||||
cfg->candidates_count++;
|
||||
tok = strtok_r(NULL, ",", &saveptr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue