MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / parse_leader_hint

Function parse_leader_hint

nodedb-cluster/src/bootstrap/join.rs:57–61  ·  view source on GitHub ↗

Parse a `JoinResponse::error` string as a leader redirect hint. The prefix is defined as a shared constant in `rpc_codec` (`LEADER_REDIRECT_PREFIX`) so the producer side (`raft_loop::join::join_flow`) and this consumer can never drift. Any other kind of rejection (collision, parse error, catalog persist failure, commit timeout, etc.) is treated as a hard failure that bubbles through the normal er

(error: &str)

Source from the content-addressed store, hash-verified

55/// expected prefix, or where the address portion does not parse
56/// as a valid `SocketAddr`.
57pub(crate) fn parse_leader_hint(error: &str) -> Option<SocketAddr> {
58 error
59 .strip_prefix(LEADER_REDIRECT_PREFIX)
60 .and_then(|s| s.trim().parse().ok())
61}
62
63/// Join an existing cluster by contacting seed nodes.
64///

Callers 1

try_join_onceFunction · 0.85

Calls 2

okMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected