Class CircuitBreakerRetry
java.lang.Object
io.micronaut.retry.intercept.CircuitBreakerRetry
- All Implemented Interfaces:
MutableRetryState, RetryState
A context object for storing the state of the Circuit.
- Since:
- 1.0
- Author:
- graemerocher
-
Constructor Summary
ConstructorsConstructorDescriptionCircuitBreakerRetry(long openTimeout, RetryStateBuilder childStateBuilder, ExecutableMethod<?, ?> method, @Nullable ApplicationEventPublisher eventPublisher, boolean throwWrappedException) Creates a circuit breaker retry state. -
Method Summary
Modifier and TypeMethodDescriptionbooleanShould a retry attempt to occur.voidCloses theRetryState.intReturns the number of the current attempt.@Nullable CircuitStateReturns the current circuit state.Returns the captured exception type, which defaults toRuntimeException.getDelay()Returns the delay between attempts.Returns the jitter factor used to apply random deviation to retry delays.intReturns the maximum number of attempts.Returns the maximum overall delay.Returns the multiplier to use between delays.Returns the overall delay so far.Returns the retry predicate checking for includes and excludes throwable classes.longReturns the millisecond value for the next delay.voidopen()Opens the retry state.
-
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 millischildStateBuilder- The retry state buildermethod- A compile time produced invocation of a method calleventPublisher- To publish circuit eventsthrowWrappedException- Iftrue, the original exception will be wrapped inCircuitOpenException
-
-
Method Details
-
close
Description copied from interface:RetryStateCloses theRetryState.- Specified by:
closein interfaceRetryState- Parameters:
exception- An exception if an error occurred or null if the operation completed as expected
-
open
public void open()Description copied from interface:RetryStateOpens the retry state.- Specified by:
openin interfaceRetryState
-
nextDelay
public long nextDelay()Description copied from interface:MutableRetryStateReturns the millisecond value for the next delay.- Specified by:
nextDelayin interfaceMutableRetryState- Returns:
- The next delay in milliseconds
-
canRetry
Description copied from interface:RetryStateShould a retry attempt to occur.- Specified by:
canRetryin interfaceRetryState- Parameters:
exception- The error- Returns:
- True if it should
-
getMaxAttempts
public int getMaxAttempts()Description copied from interface:RetryStateReturns the maximum number of attempts.- Specified by:
getMaxAttemptsin interfaceRetryState- Returns:
- The maximum number of attempts
-
currentAttempt
public int currentAttempt()Description copied from interface:RetryStateReturns the number of the current attempt.- Specified by:
currentAttemptin interfaceRetryState- Returns:
- The number of the current attempt
-
getMultiplier
Description copied from interface:RetryStateReturns the multiplier to use between delays.- Specified by:
getMultiplierin interfaceRetryState- Returns:
- The multiplier to use between delays
-
getDelay
Description copied from interface:RetryStateReturns the delay between attempts.- Specified by:
getDelayin interfaceRetryState- Returns:
- The delay between attempts
-
getOverallDelay
Description copied from interface:RetryStateReturns the overall delay so far.- Specified by:
getOverallDelayin interfaceRetryState- Returns:
- The overall delay so far
-
getMaxDelay
Description copied from interface:RetryStateReturns the maximum overall delay.- Specified by:
getMaxDelayin interfaceRetryState- Returns:
- The maximum overall delay
-
getRetryPredicate
Description copied from interface:RetryStateReturns the retry predicate checking for includes and excludes throwable classes.- Specified by:
getRetryPredicatein interfaceRetryState- Returns:
- The retry predicate checking for includes and excludes throwable classes
-
getCapturedException
Description copied from interface:RetryStateReturns the captured exception type, which defaults toRuntimeException.- Specified by:
getCapturedExceptionin interfaceRetryState- Returns:
- The captured exception type
-
getJitter
Description copied from interface:RetryStateReturns the jitter factor used to apply random deviation to retry delays.- Specified by:
getJitterin interfaceRetryState- Returns:
- The jitter factor used to apply random deviation to retry delays
-
currentState
Returns the current circuit state.- Returns:
- The current state
-