Interface CircuitBreakerConfig

interface CircuitBreakerConfig {
    name: string;
    failureThreshold: number;
    failureWindowMs: number;
    cooldownMs: number;
    halfOpenSuccessThreshold: number;
    onStateChange?: ((from, to, name) => void);
}

Properties

name: string

Unique name for this breaker (for logging/metrics).

failureThreshold: number

Number of failures before opening the circuit.

Default

5
failureWindowMs: number

Time window in ms to count failures.

Default

60000
cooldownMs: number

How long to stay open before trying half-open.

Default

30000
halfOpenSuccessThreshold: number

Number of successful probes in half-open before closing.

Default

2
onStateChange?: ((from, to, name) => void)

Optional callback when state transitions.

Type declaration