Package io.github.resilience4j.retry
Class RetryConfig
- java.lang.Object
-
- io.github.resilience4j.retry.RetryConfig
-
- All Implemented Interfaces:
java.io.Serializable
public class RetryConfig extends java.lang.Object implements java.io.Serializable- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRetryConfig.Builder<T>
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_ATTEMPTSstatic longDEFAULT_WAIT_DURATION
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> RetryConfig.Builder<T>custom()Returns a builder to create a custom RetryConfig.static <T> RetryConfig.Builder<T>from(RetryConfig baseConfig)java.util.function.Predicate<java.lang.Throwable>getExceptionPredicate()<T> io.github.resilience4j.core.IntervalBiFunction<T>getIntervalBiFunction()Return the IntervalBiFunction which calculates wait interval based on result or exceptionjava.util.function.Function<java.lang.Integer,java.lang.Long>getIntervalFunction()Deprecated.intgetMaxAttempts()<T> java.util.function.Predicate<T>getResultPredicate()Return the Predicate which evaluates if an result should be retried.booleanisFailAfterMaxAttempts()booleanisWritableStackTraceEnabled()static RetryConfigofDefaults()Creates a default Retry configuration.
-
-
-
Field Detail
-
DEFAULT_WAIT_DURATION
public static final long DEFAULT_WAIT_DURATION
- See Also:
- Constant Field Values
-
DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_MAX_ATTEMPTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
custom
public static <T> RetryConfig.Builder<T> custom()
Returns a builder to create a custom RetryConfig.- Type Parameters:
T- The type being built.- Returns:
- a
RetryConfig.Builder
-
from
public static <T> RetryConfig.Builder<T> from(RetryConfig baseConfig)
-
ofDefaults
public static RetryConfig ofDefaults()
Creates a default Retry configuration.- Returns:
- a default Retry configuration.
-
getMaxAttempts
public int getMaxAttempts()
- Returns:
- the maximum allowed attempts to make.
-
isFailAfterMaxAttempts
public boolean isFailAfterMaxAttempts()
- Returns:
- if exception should be thrown after max attempts are made with no satisfactory result
-
isWritableStackTraceEnabled
public boolean isWritableStackTraceEnabled()
- Returns:
- if any thrown
MaxRetriesExceededExceptionshould contain a stacktrace
-
getIntervalFunction
@Nullable @Deprecated public java.util.function.Function<java.lang.Integer,java.lang.Long> getIntervalFunction()
Deprecated.UseintervalBiFunctioninstead, this method is kept for backwards compatibility
-
getIntervalBiFunction
public <T> io.github.resilience4j.core.IntervalBiFunction<T> getIntervalBiFunction()
Return the IntervalBiFunction which calculates wait interval based on result or exception- Type Parameters:
T- The type of result.- Returns:
- the interval bi function
-
getExceptionPredicate
public java.util.function.Predicate<java.lang.Throwable> getExceptionPredicate()
-
getResultPredicate
@Nullable public <T> java.util.function.Predicate<T> getResultPredicate()
Return the Predicate which evaluates if an result should be retried. The Predicate must return true if the result should be retried, otherwise it must return false.- Type Parameters:
T- The type of result.- Returns:
- the result predicate
-
-