Package io.servicetalk.concurrent.api
Class RetryStrategies
java.lang.Object
io.servicetalk.concurrent.api.RetryStrategies
A set of strategies to use for retrying with
Publisher.retryWhen(BiIntFunction)
,
Single.retryWhen(BiIntFunction)
, and Completable.retryWhen(BiIntFunction)
or in general.-
Method Summary
Modifier and TypeMethodDescriptionstatic BiIntFunction<Throwable,
Completable> retryWithConstantBackoffDeltaJitter
(int maxRetries, Predicate<Throwable> causeFilter, Duration delay, Duration jitter, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithConstantBackoffDeltaJitter
(Predicate<Throwable> causeFilter, Duration delay, Duration jitter, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithConstantBackoffFullJitter
(int maxRetries, Predicate<Throwable> causeFilter, Duration delay, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithConstantBackoffFullJitter
(Predicate<Throwable> causeFilter, Duration delay, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithExponentialBackoffDeltaJitter
(int maxRetries, Predicate<Throwable> causeFilter, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithExponentialBackoffDeltaJitter
(Predicate<Throwable> causeFilter, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithExponentialBackoffFullJitter
(int maxRetries, Predicate<Throwable> causeFilter, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries.static BiIntFunction<Throwable,
Completable> retryWithExponentialBackoffFullJitter
(Predicate<Throwable> causeFilter, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries.
-
Method Details
-
retryWithConstantBackoffFullJitter
public static BiIntFunction<Throwable,Completable> retryWithConstantBackoffFullJitter(int maxRetries, Predicate<Throwable> causeFilter, Duration delay, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
maxRetries
- Maximum number of allowed retries, after which the returnedBiIntFunction
will return a failedCompletable
with the passedThrowable
as the causecauseFilter
- APredicate
that selects whether aThrowable
cause should be retrieddelay
- ConstantDuration
of delay between retriestimerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithConstantBackoffFullJitter
public static BiIntFunction<Throwable,Completable> retryWithConstantBackoffFullJitter(Predicate<Throwable> causeFilter, Duration delay, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries. This additionally adds a "Full Jitter" for the backoff as described here. a failedCompletable
with the passedThrowable
as the cause- Parameters:
causeFilter
- APredicate
that selects whether aThrowable
cause should be retrieddelay
- ConstantDuration
of delay between retriestimerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithConstantBackoffDeltaJitter
public static BiIntFunction<Throwable,Completable> retryWithConstantBackoffDeltaJitter(Predicate<Throwable> causeFilter, Duration delay, Duration jitter, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.- Parameters:
causeFilter
- APredicate
that selects whether aThrowable
cause should be retrieddelay
- ConstantDuration
of delay between retriesjitter
- The jitter to apply todelay
on each retry.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithConstantBackoffDeltaJitter
public static BiIntFunction<Throwable,Completable> retryWithConstantBackoffDeltaJitter(int maxRetries, Predicate<Throwable> causeFilter, Duration delay, Duration jitter, Executor timerExecutor) Creates a new retry function that adds the passed constantDuration
as a delay between retries.- Parameters:
maxRetries
- Maximum number of allowed retries, after which the returnedBiIntFunction
will return a failedCompletable
with the passedThrowable
as the causecauseFilter
- APredicate
that selects whether aThrowable
cause should be retrieddelay
- ConstantDuration
of delay between retriesjitter
- The jitter to apply todelay
on each retry.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithExponentialBackoffFullJitter
public static BiIntFunction<Throwable,Completable> retryWithExponentialBackoffFullJitter(Predicate<Throwable> causeFilter, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
causeFilter
- APredicate
that selects whether aThrowable
cause should be retriedinitialDelay
- DelayDuration
for the first retry and increased exponentially with each retrymaxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithExponentialBackoffFullJitter
public static BiIntFunction<Throwable,Completable> retryWithExponentialBackoffFullJitter(int maxRetries, Predicate<Throwable> causeFilter, Duration initialDelay, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
maxRetries
- Maximum number of allowed retries, after which the returnedBiIntFunction
will return a failedCompletable
with the passedThrowable
as the causecauseFilter
- APredicate
that selects whether aThrowable
cause should be retriedinitialDelay
- DelayDuration
for the first retry and increased exponentially with each retrymaxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithExponentialBackoffDeltaJitter
public static BiIntFunction<Throwable,Completable> retryWithExponentialBackoffDeltaJitter(Predicate<Throwable> causeFilter, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries.- Parameters:
causeFilter
- APredicate
that selects whether aThrowable
cause should be retriedinitialDelay
- DelayDuration
for the first retry and increased exponentially with each retryjitter
- The jitter to apply todelay
on each retry.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
retryWithExponentialBackoffDeltaJitter
public static BiIntFunction<Throwable,Completable> retryWithExponentialBackoffDeltaJitter(int maxRetries, Predicate<Throwable> causeFilter, Duration initialDelay, Duration jitter, Duration maxDelay, Executor timerExecutor) Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelay
which is increased exponentially for subsequent retries.- Parameters:
maxRetries
- Maximum number of allowed retries, after which the returnedBiIntFunction
will return a failedCompletable
with the passedThrowable
as the causecauseFilter
- APredicate
that selects whether aThrowable
cause should be retriedinitialDelay
- DelayDuration
for the first retry and increased exponentially with each retryjitter
- The jitter to apply todelay
on each retry.maxDelay
- The maximum amount of delay that will be introduced.timerExecutor
-Executor
to be used to schedule timers for backoff- Returns:
- A
BiIntFunction
to be used for retries which given a retry count and aThrowable
returns aCompletable
that terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-