@FunctionalInterface public interface RequestRetryPolicy
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DELAY |
static long |
DEFAULT_REQUEST_TIMEOUT |
Modifier and Type | Method and Description |
---|---|
boolean |
canRetryRequest(Throwable throwable)
A callback called when the request ends with an exception.
|
default long |
getDelay()
Delay that is used to wait before start attempt again.
|
default Throwable |
getPolicyException(Throwable ex)
Get an exception stating why the policy cannot repeat the request
|
default long |
getRequestTimeout()
Get timeout value for one retry attempt.
|
default <T> CompletableFuture<T> |
wrapOperation(Supplier<CompletableFuture<T>> operation,
Executor executor)
Wrap a generic operation taking an arbitrary number of arguments and returning a
CompletableFuture . |
static final int DEFAULT_DELAY
static final long DEFAULT_REQUEST_TIMEOUT
boolean canRetryRequest(Throwable throwable)
true
if and only if the request
may be performed again (e.g. it is a timeout exception and it indicates only that the current server is
overloaded). This may depend not only on the exception type, but also on the other conditions like the allowed
number of retries or the maximum request execution time.
Effective use of the retry policies may be achieved by combining them with multiple server connections and a
ConnectionSelectionStrategy
.
throwable
- exception a request failed withdefault long getRequestTimeout()
default long getDelay()
default Throwable getPolicyException(Throwable ex)
ex
- exception that will be wrappeddefault <T> CompletableFuture<T> wrapOperation(Supplier<CompletableFuture<T>> operation, Executor executor)
CompletableFuture
.
T
- operation result typeoperation
- supplier for the operation to perform. Must return a new operation instanceexecutor
- executor in which the retry callbacks will be scheduledCompletableFuture
with the same type as the operation result typeCopyright © 2025 Picodata. All rights reserved.