Skip to main content

Module failover

Module failover 

Source
Expand description

The failover decision — sticky-primary with bounded sweep. RFC 0018 §3.3.

The client’s complete() is wrapped: try the active endpoint; on a FAILOVER-CLASS error (connect refused/reset, timeout, HTTP 5xx, 429 after the endpoint’s retry, or a circuit-open skip) advance to the next available endpoint in list order; a non-failover error (401/403 auth, 4xx request, malformed body) is returned immediately (it is the same on every endpoint). On success, snap active back to the lowest-index healthy endpoint (sticky-primary) so a fallback is temporary by construction.

§3.4: the wire/adapter/JSON path is UNCHANGED — this is the only net-new control flow. Each complete_once still dials fresh (RFC 0006 §7); the only state kept between calls is the cheap per-endpoint health/breaker record.

Structs§

SweepResult
The result of one failover sweep, plus the side-channel of breaker/active transitions the caller surfaces as metrics/events (§4.3/§8) and the agentd://intelligence emission (§4.4).

Enums§

FailoverClass
How a single endpoint’s outcome is classified for failover (RFC 0018 §3.3).

Functions§

classify
Classify an IntelError for the failover sweep (RFC 0018 §3.3 table). This EXTENDS RFC 0006 §3 / RFC 0007 §3.6 — it does not redefine the per-call retry, which has already run inside complete_once before we get here.
complete_resilient
Drive one bounded failover sweep for a single logical complete (RFC 0018 §3.3). Visits at most eps.len() distinct endpoints (each at most once).
is_auth
Is this a fatal auth failure (401/403)? §6 distinguishes it from all-down: an auth failure on every endpoint is a misconfig (exit 4 immediately), NOT a backoff-loop — masking a credential error as a transient outage would hide it.
is_transient_status
HTTP statuses a same-endpoint retry may clear (RFC 0006 §7): a 429 rate-limit or an upstream 5xx blip. Mirrors the failover-class split in classify so the two never drift — a non-transient 4xx (bad request, auth) is a caller error, identical on a re-dial, and must surface immediately.