Circuit Breaker

Automatic resilience for storage backends with configurable failure thresholds, timeouts, and half-open probing.

How It Works

CLOSEDfailure_threshold →OPENtimeout →HALF_OPENsuccess →CLOSED

Configuration

RedisStorage has a built-in circuit breaker. Configuration is via constructor params:

ParameterDefaultDescription
failure_threshold5Failures before opening the circuit
recovery_timeout30sTime to wait in OPEN before probing
half_open_max_calls1Max probe calls in HALF_OPEN

Behavior

When the circuit is OPEN, all storage operations raise CircuitBreakerOpenError. The framework catches this and the bot continues running without FSM — handlers still execute, but PatchHelper operations return defaults. When Redis comes back, the circuit transitions through HALF_OPEN back to CLOSED automatically.