Interface CircuitBreaker


public interface CircuitBreaker
ServiceTalk API for a Circuit Breaker.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Forcefully open the breaker, if automatic state transition is supported it should be disabled after this call.
    void
    Releases a previously acquired permit, without influencing the breaker in any way.
    Return the name of this CircuitBreaker.
    void
    onError(long duration, TimeUnit durationUnit, Throwable throwable)
    Track a failed call and the reason.
    void
    onSuccess(long duration, TimeUnit durationUnit)
    Track a successful call.
    If the state of the breaker is open, this retrieves the remaining duration it should stay open.
    void
    Returns the circuit breaker to its original closed state and resetting any internal state (timers, metrics).
    boolean
    Attempt to acquire a permit to execute a call.
  • Method Details

    • name

      String name()
      Return the name of this CircuitBreaker.
      Returns:
      the name of this CircuitBreaker.
    • tryAcquirePermit

      boolean tryAcquirePermit()
      Attempt to acquire a permit to execute a call.
      Returns:
      true when a permit was successfully acquired.
    • ignorePermit

      void ignorePermit()
      Releases a previously acquired permit, without influencing the breaker in any way. In other words this permit is considered ignored.
    • onError

      void onError(long duration, TimeUnit durationUnit, Throwable throwable)
      Track a failed call and the reason.
      Parameters:
      duration - – The elapsed time duration of the call
      durationUnit - – The duration unit
      throwable - – The throwable which must be recorded
    • onSuccess

      void onSuccess(long duration, TimeUnit durationUnit)
      Track a successful call.
      Parameters:
      duration - The elapsed time duration of the call
      durationUnit - 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.