Heartbeat Circuit Breaker
The hospital scanner keeps failing! Build a safety switch that pauses new work, waits for recovery, and tests one careful request.
π§ Before we start
Backstage, your token bucket slowed a crowd before one door became overloaded. Today, a circuit breaker protects a sick service. It moves between three states: closed and working, open and resting, then half-open for one careful test.
Arrange the safety switch
Tap five visual instruction blocks in the order the hospital guard should follow.
Guard the scanner
Read the next request card. While the switch is closed, send it to the scanner. After three nearby failures open the switch, block new work.
Test a careful recovery
The open switch gives the scanner time to heal. Tap three cooldown heartbeats, then send exactly one test request.
working
resting
test one
Debug the forgetful counter
The buggy monitor counts every old failure forever. A successful scan should break the streak. Choose the repair.
π What you learned
- A circuit breaker protects a service that is failing again and again.
- The closed, open, and half-open states allow different actions.
- A threshold changes the state after three nearby failures.
- An open breaker blocks work during a cooldown instead of overloading the service.
- One successful half-open test closes the breaker again.
- A success resets the failure streak, so old failures do not cause a false alarm.