Skip to content

Commit 89fe1cd

Browse files
lesnik512claude
andcommitted
docs(circuit-breaker): document rate mode in the module docstring
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bab3655 commit 89fe1cd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/httpware/middleware/resilience/circuit_breaker.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""CircuitBreaker + AsyncCircuitBreaker — classic consecutive-failure circuit breaker.
1+
"""CircuitBreaker + AsyncCircuitBreaker — consecutive-failure and failure-rate circuit breakers.
22
33
See planning/specs/2026-06-13-circuit-breaker-and-timeout-design.md for the contract.
44
@@ -17,6 +17,15 @@
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+
2029
The lock-free _CircuitBreakerState holds the transition logic, shared by both wrappers.
2130
AsyncCircuitBreaker relies on asyncio atomicity (no await inside a transition) plus a
2231
single-event-loop guard; CircuitBreaker (sync) serializes transitions with a

0 commit comments

Comments
 (0)