This is a CircuitBreaker
class that has the following methods:
- Fire: To make requests
- Success: Triggered on success
- Fail: Triggered on a failure
The core idea is simple, let’s understand it with the help of a flowchart:
We start with a Closed state, meaning requests are going through. If the number of failures is more than a failureThreshold, the circuit shifts into the Open state, meaning no more requests can go through.
ref.: https://blog.logrocket.com/use-circuit-breaker-node-js/