refactor: simplify ha.c comments and extract HA config constants

- Add HA_DEFAULT_* constants to ha.h; use them in cluster_init()
- Strip stale task-label comments (P1-3a, P1-5, P1-6, P3-6 refs)
- Remove self-documenting 'Step N:' annotations from ha_do_promote/demote
- Rewrite stale forward-reference notes as current WHY comments
- Remove resolved TODO P0-8b from cluster.c
This commit is contained in:
Rongsong Shen 2026-05-08 03:56:38 +00:00
parent da6d967a33
commit d61f91b99c
3 changed files with 29 additions and 50 deletions

View file

@ -82,7 +82,6 @@ static void handle_endpoint_error(endpoint_t* ep)
if (ep->idx >= 0) {
/* zarray_del will finalize ep */
/* TODO P0-8b: replace with deferred cleanup after P0-0a zarray merge is complete */
zarray_del(&(c->endpoints), ep->idx);
return;
}
@ -632,14 +631,14 @@ int cluster_init(cluster_t* c)
}
}
/* HA initialisation — P1-5 */
/* HA initialisation */
{
ha_config_t ha_cfg = {
.heartbeat_interval_ms = 3000,
.heartbeat_timeout_ms = 10000,
.election_timeout_ms = 2000,
.probe_connect_timeout_ms = 500,
.max_promotion_retries = 5,
.heartbeat_interval_ms = HA_DEFAULT_HEARTBEAT_INTERVAL_MS,
.heartbeat_timeout_ms = HA_DEFAULT_HEARTBEAT_TIMEOUT_MS,
.election_timeout_ms = HA_DEFAULT_ELECTION_TIMEOUT_MS,
.probe_connect_timeout_ms = HA_DEFAULT_PROBE_CONNECT_TIMEOUT_MS,
.max_promotion_retries = HA_DEFAULT_MAX_PROMOTION_RETRIES,
};
/* my_priority: single-node P1 always uses 0 (highest priority) */
rc = ha_init(&c->ha, &ha_cfg, 0);