CircuitBreaker comes up with three default states: CLOSED, OPEN and HALF_OPEN
CLOSED : Everything is normal. All requests and responses are passed
OPEN : CB opens if the configured number of failure is matched
HALF_OPEN : CB waits till the duration we configure, then again it tries to CLOSE the CB by few more configured attempts. It fails again, CB goes back to CLOSE state. CB doesn't go back to CLOSED state until HALF_OPEN attempts are passed.
Below are the sample CB configurations:
ringBufferSizeInClosedState: 5 // CB is kept closed until 5 consecutive fail attempts. Then CB moves to OPEN state after 5 consecutive failures
waitDurationInOpenState: 10s // CB waits for 10 seconds in HALF_OPEN state
ringBufferSizeInHalfOpenState: 2 // CB tries 2 attempts being in HALF_OPEN state, within these 2 attempts if CB is passed, CB moves to CLOSED state. If it fails, CB moves back to OPEN state.