the current state
Implementation specific fail logic
Implementation specific fail logic
Implementation specific short circuit check
Implementation specific short circuit check
true if short circuited
Implementation specific success logic
Implementation specific success logic
Implementation specific transition logic
Implementation specific transition logic
The provided MetricRegistry will be used to register metrics
The provided MetricRegistry will be used to register metrics
the registry to use for codahale metrics
Attempts to reset breaker by transitioning to HalfOpen
state.
Attempts to reset breaker by transitioning to HalfOpen
state. This is valid from Open
state only.
Check if circuit should be short circuited.
Mark a failed element/response/call through CircuitBreaker.
Mark a successful element/response/call through CircuitBreaker.
Resets breaker to Closed
state.
Resets breaker to Closed
state. This is valid from HalfOpen
state only.
Subscribe an ActorRef to receive events that it's interested in.
Subscribe an ActorRef to receive events that it's interested in.
ActorRef that would receive the events
event types that this ActorRef is interested in
true if subscription is successful
Implements consistent transition between states.
Implements consistent transition between states. Throws IllegalStateException if an invalid transition is attempted.
State being transitioning from
State being transitioning to
Trips breaker to an open state.
Trips breaker to an open state. This is valid from Closed
or HalfOpen
states.
State we're coming from (Closed
or HalfOpen
)
Holds the state of the circuit breaker. Transitions through three states:
Closed
: elements/requests/calls run through the main logic until themaxFailures
count is reached. IfmaxFailures
is reached, it transitions toOpen
state.Open
: Short circuits. A scala.util.Failure or a fallback response is returned. AfterresetTimeout
, it transitions toHalfOpen
state.HalfOpen
: the first element/request/call will be allowed through the main logic, if it succeeds the circuit breaker will reset toClosed
state. If it fails, the circuit breaker will re-open toOpen
state. All elements/requests/calls beyond the first that execute while the first is running will fail-fast with scala.util.Failure or a fallback response.An ActorRef can be subscribed to receive certain events, e.g., TransitionEvents to receive all state transition events or specific state transition event like Open.
It collects metrics for success, failure and short-circuit counts. Also, exposes the state as a gauge.