The breaker key (typically origin/host like "https://api.example.com")
Circuit breaker configuration
The current circuit state, as of right now.
The OPEN → HALF_OPEN transition is driven by elapsed time, but it was only
ever evaluated inside execute(). A caller reading state — a health
endpoint, a dashboard, the onRejected snapshot — therefore saw a stale
OPEN for as long as no traffic arrived, and could not tell a circuit
that was about to probe from one that had been down for an hour. The
elapsed check is applied on read as well. It is a pure read: the
onHalfOpen callback still fires from execute(), so observing the state
never mutates the breaker.
Snapshot of all counters — suitable for logging or dashboards.
Per-key circuit breaker implementing the CLOSED → OPEN → HALF_OPEN state machine with sliding-window or consecutive-count failure detection.
Thread-safe for async use. Rejects with CircuitOpenError when OPEN.
Example