Fill 0003 — Circuit Breaker
A compact, testable model of the circuit breaker pattern, with a CLI to simulate state transitions.
Code: lcrc-experiments/fills/0003-circuit-breaker
Accelerator
A circuit breaker prevents cascading failures by failing fast when a downstream dependency is persistently unhealthy. Instead of accumulating queues and timeouts, traffic is stopped, then cautiously reintroduced after a cooldown.
MAPS
- States: closed → open → half-open.
- Open threshold: consecutive failures trip the breaker.
- Cooldown: time window where calls are rejected (fail-fast).
- Half-open: trial calls; enough successes close the breaker, a failure reopens it.
- Deliverable: a small Python package + CLI + unit tests.
BOB
References worth reading:
CMS
CLI example:
lcrc-breaker simulate --cooldown 2 --failure-threshold 3 --success-threshold 2 --dt 0.1 --seq ok,fail,fail,fail,call,wait:2.0,ok,ok --json
LCRCb
- Open is fail-fast until cooldown expires.
- Half-open success threshold closes; failure reopens.
- Time is injected (deterministic tests, no real sleeps).