Package io.micronaut.retry
Interface RetryState
-
public interface RetryState
An interface that encapsulates the current state of aRetryable
operation.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canRetry(java.lang.Throwable exception)
Should a retry attempt occur.default void
close(java.lang.Throwable exception)
Closes theRetryState
.int
currentAttempt()
java.lang.Class<? extends java.lang.Throwable>
getCapturedException()
java.time.Duration
getDelay()
int
getMaxAttempts()
java.util.Optional<java.time.Duration>
getMaxDelay()
java.util.OptionalDouble
getMultiplier()
java.time.Duration
getOverallDelay()
default RetryPredicate
getRetryPredicate()
default void
open()
Opens the retry state.
-
-
-
Method Detail
-
canRetry
boolean canRetry(java.lang.Throwable exception)
Should a retry attempt occur.- Parameters:
exception
- The error- Returns:
- True if it should
-
getMaxAttempts
int getMaxAttempts()
- Returns:
- The maximum number of attempts
-
currentAttempt
int currentAttempt()
- Returns:
- The number of the current attempt
-
getMultiplier
java.util.OptionalDouble getMultiplier()
- Returns:
- The multiplier to use between delays
-
getDelay
java.time.Duration getDelay()
- Returns:
- The delay between attempts
-
getOverallDelay
java.time.Duration getOverallDelay()
- Returns:
- The overall delay so far
-
getMaxDelay
java.util.Optional<java.time.Duration> getMaxDelay()
- Returns:
- The maximum overall delay
-
getRetryPredicate
default RetryPredicate getRetryPredicate()
- Returns:
- The retry predicate checking for includes/excludes throwable classes
-
getCapturedException
java.lang.Class<? extends java.lang.Throwable> getCapturedException()
- Returns:
- The captured exception type (default to
RuntimeException
-
open
default void open()
Opens the retry state.
-
close
default void close(@Nullable java.lang.Throwable exception)
Closes theRetryState
.- Parameters:
exception
- An exception if an error occurred or null if the operation completed as expected
-
-