feat(controller-status): render per-controller connection status in ctrlstatus command (task 8.3)
Adds ctrlstatus_peer_status_str (mirrors ctrlstatus_role_str's convention: 0=unknown/1=ok/2=catching-up/3=dead, safe default fallback for any other code) and extends cmd_ctrlstatus's per-controller print line to render it alongside each configured controller's existing name:address, completing the CtrlPeer.status wire field added in task 8.1 and sourced in task 8.2. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RLSNJhNoULvVcUhXEFafQC
This commit is contained in:
parent
ab5dd91537
commit
64b18d5c34
2 changed files with 25 additions and 3 deletions
|
|
@ -3004,6 +3004,27 @@ static const char* ctrlstatus_role_str(uint8_t role)
|
|||
}
|
||||
}
|
||||
|
||||
/* Map a CtrlPeer.status raw value (controller-status Req 13 delta,
|
||||
* design.md "Design Delta — Requirement 13", Locked Decision 2 / schema
|
||||
* delta) to a display string. UNKNOWN==0, OK==1, CATCHING_UP==2, DEAD==3;
|
||||
* anything else is reported verbatim so an unexpected code is never
|
||||
* silently rendered as a known one (mirrors ctrlstatus_role_str above). */
|
||||
static const char* ctrlstatus_peer_status_str(uint8_t status)
|
||||
{
|
||||
switch (status) {
|
||||
case 0:
|
||||
return "unknown";
|
||||
case 1:
|
||||
return "ok";
|
||||
case 2:
|
||||
return "catching-up";
|
||||
case 3:
|
||||
return "dead";
|
||||
default:
|
||||
return "unknown-status";
|
||||
}
|
||||
}
|
||||
|
||||
/* `ctrlstatus` (controller-status task 4.1, Req 1.3/3.3/5.1/5.2/8.1/8.2/8.3,
|
||||
* design.md "cmd_ctrlstatus (test client) — State contract").
|
||||
*
|
||||
|
|
@ -3149,8 +3170,9 @@ int cmd_ctrlstatus(int argc, char* argv[])
|
|||
continue;
|
||||
}
|
||||
|
||||
printf("\t%s\t%s:%u\n", NULLSTR(peer->name) ? "?" : peer->name,
|
||||
NULLSTR(peer->host) ? "?" : peer->host, peer->port);
|
||||
printf("\t%s\t%s:%u\t%s\n", NULLSTR(peer->name) ? "?" : peer->name,
|
||||
NULLSTR(peer->host) ? "?" : peer->host, peer->port,
|
||||
ctrlstatus_peer_status_str(peer->status));
|
||||
}
|
||||
|
||||
/* Config version + committed config version (Req 5.1) and the content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue