Interface CircuitBreaker
public interface CircuitBreaker
ServiceTalk API for a Circuit Breaker.
-
Method Summary
Modifier and TypeMethodDescriptionvoidForcefully open the breaker, if automatic state transition is supported it should be disabled after this call.voidReleases a previouslyacquiredpermit, without influencing the breaker in any way.name()Return the name of thisCircuitBreaker.voidTrack a failed call and the reason.voidTrack a successful call.If the state of the breaker is open, this retrieves the remaining duration it should stay open.voidreset()Returns the circuit breaker to its original closed state and resetting any internal state (timers, metrics).booleanAttempt to acquire a permit to execute a call.
-
Method Details
-
name
String name()Return the name of thisCircuitBreaker.- Returns:
- the name of this
CircuitBreaker.
-
tryAcquirePermit
boolean tryAcquirePermit()Attempt to acquire a permit to execute a call.- Returns:
truewhen a permit was successfully acquired.
-
ignorePermit
void ignorePermit()Releases a previouslyacquiredpermit, without influencing the breaker in any way. In other words this permit is considered ignored. -
onError
Track a failed call and the reason.- Parameters:
duration- – The elapsed time duration of the calldurationUnit- – The duration unitthrowable- – The throwable which must be recorded
-
onSuccess
Track a successful call.- Parameters:
duration- The elapsed time duration of the calldurationUnit- The duration unit
-
forceOpenState
void forceOpenState()Forcefully open the breaker, if automatic state transition is supported it should be disabled after this call. -
reset
void reset()Returns the circuit breaker to its original closed state and resetting any internal state (timers, metrics). -
remainingDurationInOpenState
Duration remainingDurationInOpenState()If the state of the breaker is open, this retrieves the remaining duration it should stay open. Expectation is that after this duration, the breaker shall allow/offer more permits.- Returns:
- The remaining duration that the breaker will remain open.
-