Akka's CircuitBreaker
feedback logic to test the result
ExecutionContext
Wraps a call in this circuit breaker.
Wraps a call in this circuit breaker.
call that needs protected
the result of body
with this Failurewall
a failed future with FailurewallException if a call is rejected
A circuit breaker with Failurewall's interface implemented by Akka's CircuitBreaker. Calls wrapped in AkkaCircuitBreakerFailurewall are protected by circuit breaker mechanisms. A circuit breaker prevents a failure form cascading any other failures.
A circuit breaker is a state machine that has a following state.
- CLOSED - OPEN - HALF-OPEN
The
CLOSED
state is the ordinary state. In this state, calls are executed and failure statistics are recorded. When failure count exceeds the threshold, the circuit breaker switches into theOPEN
state.The
OPEN
state is the state under problems. In this state,call
never executes thebody
and returns an error immediately, so-calledfail-fast
. TheOPEN
state prevents applications from accessing resources under problems. After the configured timeout, the circuit breaker switches into theHALF-OPEN
state.The
HALF-OPEN
state is the challenge phase. In this state, the firstcall
executes thebody
in order to test that the problem is fixed. The other calls never execute bodies and return errors immediately. If the first call succeeds, the circuit breaker switches toCLOSED
state. If the first call fails, the circuit breaker switches toOPEN
state.