@ferrow/circuit-breaker
v1.0.0
Published

Maintainers
Readme
Circuit Breaker
Stop calling failing services. Prevent cascade failures.
const breaker = new CircuitBreaker(() => flakeyAPI(), { threshold: 5, resetTimeoutMs: 30000 });
try { await breaker.execute(); }
catch (e) { /* service is down, fail fast */ }States
CLOSED: calls pass through normally; failures are counted.OPEN: calls fail fast oncethresholdconsecutive failures are hit.HALF_OPEN: afterresetTimeoutMselapses, the next call is allowed through as a trial; success closes the circuit, failure re-opens it.
Solves: Cascade failures, resource exhaustion, graceful degradation. License: MIT
Sponsored by Ferrow
Part of the ferrow-toolkit collection · Sponsored by Ferrow
