public final class RetryStrategies
extends java.lang.Object
Publisher.retryWhen(BiIntFunction)
,
Single.retryWhen(BiIntFunction)
, and Completable.retryWhen(BiIntFunction)
or in general.Modifier and Type | Method and Description |
---|---|
static BiIntFunction<java.lang.Throwable,Completable> |
retryWithConstantBackoff(int maxRetries,
java.util.function.Predicate<java.lang.Throwable> causeFilter,
java.time.Duration delay,
Executor timerExecutor)
Creates a new retry function that adds the passed constant
Duration as a delay between retries. |
static BiIntFunction<java.lang.Throwable,Completable> |
retryWithConstantBackoffAndJitter(int maxRetries,
java.util.function.Predicate<java.lang.Throwable> causeFilter,
java.time.Duration delay,
Executor timerExecutor)
Creates a new retry function that adds the passed constant
Duration as a delay between retries. |
static BiIntFunction<java.lang.Throwable,Completable> |
retryWithExponentialBackoff(int maxRetries,
java.util.function.Predicate<java.lang.Throwable> causeFilter,
java.time.Duration initialDelay,
Executor timerExecutor)
Creates a new retry function that adds a delay between retries.
|
static BiIntFunction<java.lang.Throwable,Completable> |
retryWithExponentialBackoffAndJitter(int maxRetries,
java.util.function.Predicate<java.lang.Throwable> causeFilter,
java.time.Duration initialDelay,
Executor timerExecutor)
Creates a new retry function that adds a delay between retries.
|
public static BiIntFunction<java.lang.Throwable,Completable> retryWithConstantBackoff(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, Executor timerExecutor)
Duration
as a delay between retries.maxRetries
- Maximum number of allowed retries, after which the returned BiIntFunction
will return
a failed Completable
with the passed Throwable
as the causecauseFilter
- A Predicate
that selects whether a Throwable
cause should be retrieddelay
- Constant Duration
of delay between retriestimerExecutor
- Executor
to be used to schedule timers for backoffBiIntFunction
to be used for retries which given a retry count and a Throwable
returns
a Completable
that terminates successfully when the source has to be retried or terminates with error
if the source should not be retried for the passed Throwable
public static BiIntFunction<java.lang.Throwable,Completable> retryWithConstantBackoffAndJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, Executor timerExecutor)
Duration
as a delay between retries.
This additionally adds a "Full Jitter" for the backoff as described
here.maxRetries
- Maximum number of allowed retries, after which the returned BiIntFunction
will return
a failed Completable
with the passed Throwable
as the causecauseFilter
- A Predicate
that selects whether a Throwable
cause should be retrieddelay
- Constant Duration
of delay between retriestimerExecutor
- Executor
to be used to schedule timers for backoffBiIntFunction
to be used for retries which given a retry count and a Throwable
returns
a Completable
that terminates successfully when the source has to be retried or terminates with error
if the source should not be retried for the passed Throwable
public static BiIntFunction<java.lang.Throwable,Completable> retryWithExponentialBackoff(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, Executor timerExecutor)
initialDelay
which is increased exponentially for subsequent retries.
This method may not attempt to check for overflow if the retry count is high enough that an exponential delay
causes Long
overflow.
maxRetries
- Maximum number of allowed retries, after which the returned BiIntFunction
will return
a failed Completable
with the passed Throwable
as the causecauseFilter
- A Predicate
that selects whether a Throwable
cause should be retriedinitialDelay
- Delay Duration
for the first retry and increased exponentially with each retrytimerExecutor
- Executor
to be used to schedule timers for backoffBiIntFunction
to be used for retries which given a retry count and a Throwable
returns
a Completable
that terminates successfully when the source has to be retried or terminates with error
if the source should not be retried for the passed Throwable
public static BiIntFunction<java.lang.Throwable,Completable> retryWithExponentialBackoffAndJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, Executor timerExecutor)
initialDelay
which is increased exponentially for subsequent retries.
This additionally adds a "Full Jitter" for the backoff as described
here.
This method may not attempt to check for overflow if the retry count is high enough that an exponential delay
causes Long
overflow.
maxRetries
- Maximum number of allowed retries, after which the returned BiIntFunction
will return
a failed Completable
with the passed Throwable
as the causecauseFilter
- A Predicate
that selects whether a Throwable
cause should be retriedinitialDelay
- Delay Duration
for the first retry and increased exponentially with each retrytimerExecutor
- Executor
to be used to schedule timers for backoffBiIntFunction
to be used for retries which given a retry count and a Throwable
returns
a Completable
that terminates successfully when the source has to be retried or terminates with error
if the source should not be retried for the passed Throwable