Class Retry
java.lang.Object
co.yellowdog.platform.clients.retry.Retry
Manages retry logic.
This will always use an exponential backoff algorithm with jitter.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Retry.Builder<T> TRetry the given supplier.<T> CompletableFuture<T> retryAsync(Supplier<CompletionStage<T>> retryable) Asynchronously retry the given async supplier.withMaxAttempts(long maxAttempts) A copy of this retry that stops after the given number of attempts to retry, in place of this one's maximum.
-
Method Details
-
builder
-
withMaxAttempts
A copy of this retry that stops after the given number of attempts to retry, in place of this one's maximum.- Parameters:
maxAttempts- the maximum number of attempts to retry.- Returns:
- the copy.
- Throws:
IllegalArgumentException- if maxAttempts is less than 0.
-
retry
Retry the given supplier. Any exceptions thrown by the supplier will result in a retry.- Type Parameters:
T- the type of the result.- Parameters:
retryable- the supplier to retry.- Returns:
- the result of the supplier.
-
retryAsync
Asynchronously retry the given async supplier. Any exceptions thrown by the supplier will result in a retry.- Type Parameters:
T- the type of the result.- Parameters:
retryable- the async supplier to retry.- Returns:
- the future to wait on for the result.
-