File tree Expand file tree Collapse file tree
src/httpware/middleware/resilience Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- """CircuitBreaker + AsyncCircuitBreaker — classic consecutive-failure circuit breaker .
1+ """CircuitBreaker + AsyncCircuitBreaker — consecutive-failure and failure-rate circuit breakers .
22
33See planning/specs/2026-06-13-circuit-breaker-and-timeout-design.md for the contract.
44
1717 HALF_OPEN — admit exactly one probe at a time; success_threshold consecutive probe
1818 successes close the circuit; one probe failure re-opens it.
1919
20+ Trip modes:
21+ Classic (default) — opens when consecutive counted-failures reach failure_threshold.
22+ Set failure_threshold to use this mode; leave failure_rate_threshold unset.
23+ Rate (opt-in) — opens when the failure rate over a rolling window_seconds window
24+ meets or exceeds failure_rate_threshold, provided at least minimum_calls
25+ outcomes have been observed in that window. Set failure_rate_threshold to
26+ activate; failure_threshold is ignored in this mode.
27+ Half-open recovery and event names are identical across both modes.
28+
2029The lock-free _CircuitBreakerState holds the transition logic, shared by both wrappers.
2130AsyncCircuitBreaker relies on asyncio atomicity (no await inside a transition) plus a
2231single-event-loop guard; CircuitBreaker (sync) serializes transitions with a
You can’t perform that action at this time.
0 commit comments