The circuit breaker involves allowing the application to disable a code path if it is known or estimated as failing.
For instance, if you call a remote service and this service has failed 10 times already, then you can say: don't call this service anymore for 5 minutes. The main idea is to bypass errors when possible.
A circuit breaker generally has three states:
- CLOSED: The system is considered to be working, so use it (default case).
- OPEN: The system is considered not working, so bypass it.
- HALF-OPEN: The system must be reevaluated. Try an invocation: if it fails, go back to the OPEN state; otherwise, go to the CLOSED state.
Then, all the conditions to go from a state to the other are configurable. For instance, what triggers ...