public final class Retries
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.util.function.Predicate<java.lang.Throwable> |
NonFatalPredicate |
| Modifier and Type | Method and Description |
|---|---|
static <ReturnT> java.util.concurrent.CompletableFuture<ReturnT> |
run(java.util.stream.Stream<java.lang.Long> backoffs,
java.util.function.Predicate<java.lang.Throwable> retryPredicate,
java.util.function.Supplier<java.util.concurrent.CompletableFuture<ReturnT>> task,
OrderedScheduler scheduler)
Retry a given
task on failures. |
static <ReturnT> java.util.concurrent.CompletableFuture<ReturnT> |
run(java.util.stream.Stream<java.lang.Long> backoffs,
java.util.function.Predicate<java.lang.Throwable> retryPredicate,
java.util.function.Supplier<java.util.concurrent.CompletableFuture<ReturnT>> task,
OrderedScheduler scheduler,
java.lang.Object key)
Retry a given
task on failures. |
public static final java.util.function.Predicate<java.lang.Throwable> NonFatalPredicate
public static <ReturnT> java.util.concurrent.CompletableFuture<ReturnT> run(java.util.stream.Stream<java.lang.Long> backoffs,
java.util.function.Predicate<java.lang.Throwable> retryPredicate,
java.util.function.Supplier<java.util.concurrent.CompletableFuture<ReturnT>> task,
OrderedScheduler scheduler)
task on failures.
It is a shortcut of run(Stream, Predicate, Supplier, OrderedScheduler, Object)
that runs retries on any threads in the provided scheduler.
ReturnT - the return typebackoffs - a stream of backoff delays, in milliseconds.retryPredicate - a predicate to test if failures are retryable.task - a task to execute.scheduler - scheduler to schedule the task and complete the futures.public static <ReturnT> java.util.concurrent.CompletableFuture<ReturnT> run(java.util.stream.Stream<java.lang.Long> backoffs,
java.util.function.Predicate<java.lang.Throwable> retryPredicate,
java.util.function.Supplier<java.util.concurrent.CompletableFuture<ReturnT>> task,
OrderedScheduler scheduler,
java.lang.Object key)
task on failures.
It will only retry the tasks when the predicate retryPredicate tests
it as a retryable failure and it doesn't exhaust the retry budget. The retry delays
are defined in a stream of delay values (in milliseconds).
If a schedule key is provided, the task will be submitted to the
scheduler using the provided schedule key and also the returned future
will be completed in the same thread. Otherwise, the task and the returned future will
be executed and scheduled on any threads in the scheduler.
ReturnT - the return tye.backoffs - a stream of backoff delays, in milliseconds.retryPredicate - a predicate to test if failures are retryable.task - a task to execute.scheduler - scheduler to schedule the task and complete the futures.key - the submit key for the scheduler.Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.