Expand description
Circuit breaker.
Three states:
- Closed — calls go through; consecutive failures are counted.
When the count hits
failure_threshold, the breaker trips toOpen. - Open — calls are rejected with
ToolkitError::CircuitOpenuntilcool_downhas elapsed since the trip. Then the breaker moves toHalfOpen. - HalfOpen — only
half_open_max_callscalls are admitted. If they all succeed, the breaker returns toClosed. A single failure trips it back toOpen.
The implementation deliberately uses a single Mutex for the state machine. Breakers protect expensive downstream calls — the cost of locking is dwarfed by the network/IO cost of the call itself.
Structs§
- Circuit
Breaker - A circuit breaker. Cheap to
clone; the inner state isArc<Mutex<_>>. - Circuit
Breaker Builder - Builder for
CircuitBreaker.
Enums§
- Circuit
State - Current state of the breaker.