Package org.apache.pekko.pattern
Interface CircuitBreaker.State
- Enclosing class:
- CircuitBreaker
public static interface CircuitBreaker.State
Internal state abstraction
-
Method Summary
Modifier and TypeMethodDescriptionvoid_enter()Template method for concrete traitsvoidaddListener(Runnable listener) Add a listener function which is invoked on state entryvoidInvoked when call failsvoidInvoked when call succeeds<T> scala.concurrent.Future<T>callThrough(scala.Function0<scala.concurrent.Future<T>> body) Shared implementation of call across all states.<T> scala.concurrent.Future<T>callThrough(scala.Function0<scala.concurrent.Future<T>> body, scala.Function1<scala.util.Try<T>, Object> defineFailureFn) Shared implementation of call across all states.voidenter()Invoked on the transitioned-to state during transition.booleanTest for whether listeners exist<T> scala.concurrent.Future<T>invoke(scala.Function0<scala.concurrent.Future<T>> body) Abstract entry point for all states<T> scala.concurrent.Future<T>invoke(scala.Function0<scala.concurrent.Future<T>> body, scala.Function1<scala.util.Try<T>, Object> defineFailureFn) Abstract entry point for all statesvoidNotifies the listeners of the transition event via a Future executed in implicit parameter ExecutionContext
-
Method Details
-
_enter
void _enter()Template method for concrete traits -
addListener
Add a listener function which is invoked on state entry- Parameters:
listener- listener implementation
-
callFails
void callFails()Invoked when call fails -
callSucceeds
void callSucceeds()Invoked when call succeeds -
callThrough
<T> scala.concurrent.Future<T> callThrough(scala.Function0<scala.concurrent.Future<T>> body, scala.Function1<scala.util.Try<T>, Object> defineFailureFn) Shared implementation of call across all states. Thrown exception or execution of the call beyond the allowed call timeout is counted as a failed call, otherwise a successful call- Parameters:
body- Implementation of the calldefineFailureFn- function that define what should be consider failure and thus increase failure count- Returns:
- Future containing the result of the call
-
callThrough
<T> scala.concurrent.Future<T> callThrough(scala.Function0<scala.concurrent.Future<T>> body) Shared implementation of call across all states. Thrown exception or execution of the call beyond the allowed call timeout is counted as a failed call, otherwise a successful call- Parameters:
body- Implementation of the call- Returns:
- Future containing the result of the call
-
enter
void enter()Invoked on the transitioned-to state during transition. Notifies listeners after invoking subclass template method _enter -
hasListeners
boolean hasListeners()Test for whether listeners exist- Returns:
- whether listeners exist
-
invoke
<T> scala.concurrent.Future<T> invoke(scala.Function0<scala.concurrent.Future<T>> body, scala.Function1<scala.util.Try<T>, Object> defineFailureFn) Abstract entry point for all states- Parameters:
body- Implementation of the call that needs protecteddefineFailureFn- function that define what should be consider failure and thus increase failure count- Returns:
- Future containing result of protected call
-
invoke
<T> scala.concurrent.Future<T> invoke(scala.Function0<scala.concurrent.Future<T>> body) Abstract entry point for all states- Parameters:
body- Implementation of the call that needs protected- Returns:
- Future containing result of protected call
-
notifyTransitionListeners
void notifyTransitionListeners()Notifies the listeners of the transition event via a Future executed in implicit parameter ExecutionContext
-