Expand description
Circuit breaker (api-breaker), ported from APISIX’s
apisix/plugins/api-breaker.lua.
A circuit breaker must both decide whether to admit a request (before the
upstream call) and observe the outcome (after it) — two moments a single
featherbit node cannot span. The behavior is expressed as a pair of
nodes sharing one breaker, linked by a required id:
- a check node placed before
upstream, which trips to the short-circuit response while the breaker is open, and - an observe node placed after
upstream, which feeds the response status back into the breaker so it opens and closes.
Both nodes carry the same id, so crate::traffic::BreakerRegistry hands
them the same crate::traffic::BreakerState.
§Wiring
┌──────────────────┐ ┌──────────┐ ┌──────────────────┐
listener →│ api-breaker │success →│ upstream │─ any ─→│ api-breaker │→ client
│ (phase=check) │ │ │ │ (phase=observe) │
└──────────────────┘ └──────────┘ └──────────────────┘
│ error (records the
▼ upstream status into
client.in the shared breaker)
(break_response_code)The check node’s error port goes to client.in: while the breaker is open
the request short-circuits to the client with the configured break response.
The observe node passes the response through untouched and simply records
the status; wire it on the path(s) out of upstream that carry the real
upstream response.
Structs§
- ApiBreaker
Plugin - One node of an
api-breakercheck/observe pair.
Enums§
- Role 🔒
- Which half of the pair this node is.
Functions§
- parse_
statuses 🔒 - Reads a
Vec<u16>of HTTP statuses from a JSON array, if present and valid.