Package io.servicetalk.concurrent.api
Class RetryStrategies
- java.lang.Object
-
- io.servicetalk.concurrent.api.RetryStrategies
-
public final class RetryStrategies extends java.lang.ObjectA set of strategies to use for retrying withPublisher.retryWhen(BiIntFunction),Single.retryWhen(BiIntFunction), andCompletable.retryWhen(BiIntFunction)or in general.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BiIntFunction<java.lang.Throwable,Completable>retryWithConstantBackoffDeltaJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)Creates a new retry function that adds the passed constantDurationas a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithConstantBackoffDeltaJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)Creates a new retry function that adds the passed constantDurationas a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithConstantBackoffFullJitter(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 constantDurationas a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithConstantBackoffFullJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, Executor timerExecutor)Creates a new retry function that adds the passed constantDurationas a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithExponentialBackoffDeltaJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retry function that adds a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithExponentialBackoffDeltaJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retry function that adds a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithExponentialBackoffFullJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retry function that adds a delay between retries.static BiIntFunction<java.lang.Throwable,Completable>retryWithExponentialBackoffFullJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)Creates a new retry function that adds a delay between retries.
-
-
-
Method Detail
-
retryWithConstantBackoffFullJitter
public static BiIntFunction<java.lang.Throwable,Completable> retryWithConstantBackoffFullJitter(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 constantDurationas 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 returnedBiIntFunctionwill return a failedCompletablewith the passedThrowableas the causecauseFilter- APredicatethat selects whether aThrowablecause should be retrieddelay- ConstantDurationof delay between retriestimerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithConstantBackoffFullJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, Executor timerExecutor)
Creates a new retry function that adds the passed constantDurationas a delay between retries. This additionally adds a "Full Jitter" for the backoff as described here. a failedCompletablewith the passedThrowableas the cause- Parameters:
causeFilter- APredicatethat selects whether aThrowablecause should be retrieddelay- ConstantDurationof delay between retriestimerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithConstantBackoffDeltaJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new retry function that adds the passed constantDurationas a delay between retries.- Parameters:
causeFilter- APredicatethat selects whether aThrowablecause should be retrieddelay- ConstantDurationof delay between retriesjitter- The jitter to apply todelayon each retry.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithConstantBackoffDeltaJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration delay, java.time.Duration jitter, Executor timerExecutor)
Creates a new retry function that adds the passed constantDurationas a delay between retries.- Parameters:
maxRetries- Maximum number of allowed retries, after which the returnedBiIntFunctionwill return a failedCompletablewith the passedThrowableas the causecauseFilter- APredicatethat selects whether aThrowablecause should be retrieddelay- ConstantDurationof delay between retriesjitter- The jitter to apply todelayon each retry.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithExponentialBackoffFullJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries. This additionally adds a "Full Jitter" for the backoff as described here.- Parameters:
causeFilter- APredicatethat selects whether aThrowablecause should be retriedinitialDelay- DelayDurationfor the first retry and increased exponentially with each retrymaxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithExponentialBackoffFullJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelaywhich 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 returnedBiIntFunctionwill return a failedCompletablewith the passedThrowableas the causecauseFilter- APredicatethat selects whether aThrowablecause should be retriedinitialDelay- DelayDurationfor the first retry and increased exponentially with each retrymaxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithExponentialBackoffDeltaJitter(java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries.- Parameters:
causeFilter- APredicatethat selects whether aThrowablecause should be retriedinitialDelay- DelayDurationfor the first retry and increased exponentially with each retryjitter- The jitter to apply todelayon each retry.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat 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<java.lang.Throwable,Completable> retryWithExponentialBackoffDeltaJitter(int maxRetries, java.util.function.Predicate<java.lang.Throwable> causeFilter, java.time.Duration initialDelay, java.time.Duration jitter, java.time.Duration maxDelay, Executor timerExecutor)
Creates a new retry function that adds a delay between retries. For first retry, the delay isinitialDelaywhich is increased exponentially for subsequent retries.- Parameters:
maxRetries- Maximum number of allowed retries, after which the returnedBiIntFunctionwill return a failedCompletablewith the passedThrowableas the causecauseFilter- APredicatethat selects whether aThrowablecause should be retriedinitialDelay- DelayDurationfor the first retry and increased exponentially with each retryjitter- The jitter to apply todelayon each retry.maxDelay- The maximum amount of delay that will be introduced.timerExecutor-Executorto be used to schedule timers for backoff- Returns:
- A
BiIntFunctionto be used for retries which given a retry count and aThrowablereturns aCompletablethat terminates successfully when the source has to be retried or terminates with error if the source should not be retried for the passedThrowable
-
-