Package io.github.resilience4j.retry
Class RetryConfig.Builder<T>
- java.lang.Object
-
- io.github.resilience4j.retry.RetryConfig.Builder<T>
-
- Enclosing class:
- RetryConfig
public static class RetryConfig.Builder<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Builder()Builder(RetryConfig baseConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryConfigbuild()RetryConfig.Builder<T>ignoreExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)Configures a list of error classes that are ignored and thus are not retried.RetryConfig.Builder<T>intervalFunction(io.github.resilience4j.core.IntervalFunction f)Set a function to modify the waiting interval after a failure.RetryConfig.Builder<T>maxAttempts(int maxAttempts)RetryConfig.Builder<T>retryExceptions(java.lang.Class<? extends java.lang.Throwable>... errorClasses)Configures a list of error classes that are recorded as a failure and thus are retried.RetryConfig.Builder<T>retryOnException(java.util.function.Predicate<java.lang.Throwable> predicate)Configures a Predicate which evaluates if an exception should be retried.RetryConfig.Builder<T>retryOnResult(java.util.function.Predicate<T> predicate)Configures a Predicate which evaluates if an result should be retried.RetryConfig.Builder<T>waitDuration(java.time.Duration waitDuration)
-
-
-
Constructor Detail
-
Builder
public Builder()
-
Builder
public Builder(RetryConfig baseConfig)
-
-
Method Detail
-
maxAttempts
public RetryConfig.Builder<T> maxAttempts(int maxAttempts)
-
waitDuration
public RetryConfig.Builder<T> waitDuration(java.time.Duration waitDuration)
-
retryOnResult
public RetryConfig.Builder<T> retryOnResult(java.util.function.Predicate<T> predicate)
Configures a 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.- Parameters:
predicate- the Predicate which evaluates if an result should be retried or not.- Returns:
- the RetryConfig.Builder
-
intervalFunction
public RetryConfig.Builder<T> intervalFunction(io.github.resilience4j.core.IntervalFunction f)
Set a function to modify the waiting interval after a failure. By default the interval stays the same.- Parameters:
f- Function to modify the interval after a failure- Returns:
- the RetryConfig.Builder
-
retryOnException
public RetryConfig.Builder<T> retryOnException(java.util.function.Predicate<java.lang.Throwable> predicate)
Configures a Predicate which evaluates if an exception should be retried. The Predicate must return true if the exception should be retried, otherwise it must return false.- Parameters:
predicate- the Predicate which evaluates if an exception should be retried or not.- Returns:
- the RetryConfig.Builder
-
retryExceptions
@SafeVarargs public final RetryConfig.Builder<T> retryExceptions(@Nullable java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Configures a list of error classes that are recorded as a failure and thus are retried. Any exception matching or inheriting from one of the list will be retried, unless ignored via- Parameters:
errorClasses- the error classes that are retried- Returns:
- the RetryConfig.Builder
- See Also:
). Ignoring an exception has priority over retrying an exception. Example: retryOnExceptions(Throwable.class) and ignoreExceptions(RuntimeException.class) would retry all Errors and checked Exceptions, and ignore unchecked For a more sophisticated exception management use the,method
-
ignoreExceptions
@SafeVarargs public final RetryConfig.Builder<T> ignoreExceptions(@Nullable java.lang.Class<? extends java.lang.Throwable>... errorClasses)
Configures a list of error classes that are ignored and thus are not retried. Any exception matching or inheriting from one of the list will not be retried, even if marked via- Parameters:
errorClasses- the error classes that are retried- Returns:
- the RetryConfig.Builder
- See Also:
. Ignoring an exception has priority over retrying an exception. Example: ignoreExceptions(Throwable.class) and retryOnExceptions(Exception.class) would capture nothing Example: ignoreExceptions(Exception.class) and retryOnExceptions(Throwable.class) would capture Errors For a more sophisticated exception management use the,method
-
build
public RetryConfig build()
-
-