Class CircuitBreakerRetry

java.lang.Object
io.micronaut.retry.intercept.CircuitBreakerRetry
All Implemented Interfaces:
MutableRetryState, RetryState

@Internal public class CircuitBreakerRetry extends Object implements MutableRetryState
A context object for storing the state of the Circuit.
Since:
1.0
Author:
graemerocher
  • Constructor Details

    • CircuitBreakerRetry

      public CircuitBreakerRetry(long openTimeout, RetryStateBuilder childStateBuilder, ExecutableMethod<?,?> method, @Nullable ApplicationEventPublisher eventPublisher, boolean throwWrappedException)
      Creates a circuit breaker retry state.
      Parameters:
      openTimeout - The circuit open timeout in millis
      childStateBuilder - The retry state builder
      method - A compile time produced invocation of a method call
      eventPublisher - To publish circuit events
      throwWrappedException - If true, the original exception will be wrapped in CircuitOpenException
  • Method Details

    • close

      public void close(@Nullable Throwable exception)
      Description copied from interface: RetryState
      Closes the RetryState.
      Specified by:
      close in interface RetryState
      Parameters:
      exception - An exception if an error occurred or null if the operation completed as expected
    • open

      public void open()
      Description copied from interface: RetryState
      Opens the retry state.
      Specified by:
      open in interface RetryState
    • nextDelay

      public long nextDelay()
      Description copied from interface: MutableRetryState
      Returns the millisecond value for the next delay.
      Specified by:
      nextDelay in interface MutableRetryState
      Returns:
      The next delay in milliseconds
    • canRetry

      public boolean canRetry(Throwable exception)
      Description copied from interface: RetryState
      Should a retry attempt to occur.
      Specified by:
      canRetry in interface RetryState
      Parameters:
      exception - The error
      Returns:
      True if it should
    • getMaxAttempts

      public int getMaxAttempts()
      Description copied from interface: RetryState
      Returns the maximum number of attempts.
      Specified by:
      getMaxAttempts in interface RetryState
      Returns:
      The maximum number of attempts
    • currentAttempt

      public int currentAttempt()
      Description copied from interface: RetryState
      Returns the number of the current attempt.
      Specified by:
      currentAttempt in interface RetryState
      Returns:
      The number of the current attempt
    • getMultiplier

      public OptionalDouble getMultiplier()
      Description copied from interface: RetryState
      Returns the multiplier to use between delays.
      Specified by:
      getMultiplier in interface RetryState
      Returns:
      The multiplier to use between delays
    • getDelay

      public Duration getDelay()
      Description copied from interface: RetryState
      Returns the delay between attempts.
      Specified by:
      getDelay in interface RetryState
      Returns:
      The delay between attempts
    • getOverallDelay

      public Duration getOverallDelay()
      Description copied from interface: RetryState
      Returns the overall delay so far.
      Specified by:
      getOverallDelay in interface RetryState
      Returns:
      The overall delay so far
    • getMaxDelay

      public Optional<Duration> getMaxDelay()
      Description copied from interface: RetryState
      Returns the maximum overall delay.
      Specified by:
      getMaxDelay in interface RetryState
      Returns:
      The maximum overall delay
    • getRetryPredicate

      public RetryPredicate getRetryPredicate()
      Description copied from interface: RetryState
      Returns the retry predicate checking for includes and excludes throwable classes.
      Specified by:
      getRetryPredicate in interface RetryState
      Returns:
      The retry predicate checking for includes and excludes throwable classes
    • getCapturedException

      public @Nullable Class<? extends Throwable> getCapturedException()
      Description copied from interface: RetryState
      Returns the captured exception type, which defaults to RuntimeException.
      Specified by:
      getCapturedException in interface RetryState
      Returns:
      The captured exception type
    • getJitter

      public OptionalDouble getJitter()
      Description copied from interface: RetryState
      Returns the jitter factor used to apply random deviation to retry delays.
      Specified by:
      getJitter in interface RetryState
      Returns:
      The jitter factor used to apply random deviation to retry delays
    • currentState

      public @Nullable CircuitState currentState()
      Returns the current circuit state.
      Returns:
      The current state