Package io.tarantool.driver.api.retry
Interface RequestRetryPolicy
-
- All Known Implementing Classes:
TarantoolRequestRetryPolicies.AttemptsBoundRetryPolicy
,TarantoolRequestRetryPolicies.InfiniteRetryPolicy
public interface RequestRetryPolicy
Request retry policy contains an algorithm of deciding whether an exception is retryable and settings for limiting the retry attempts
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
canRetryRequest(Throwable throwable)
A callback called when the request ends with an exception.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 aCompletableFuture
.
-
-
-
Method Detail
-
canRetryRequest
boolean canRetryRequest(Throwable throwable)
A callback called when the request ends with an exception. Should returntrue
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
.- Parameters:
throwable
- exception a request failed with- Returns:
- true if the request may be retried
-
getRequestTimeout
default long getRequestTimeout()
Get timeout value for one retry attempt. The default value is 1 hour.- Returns:
- timeout value (ms), should be greater or equal to 0
-
wrapOperation
default <T> CompletableFuture<T> wrapOperation(Supplier<CompletableFuture<T>> operation, Executor executor)
Wrap a generic operation taking an arbitrary number of arguments and returning aCompletableFuture
. Each operation attempt is limited with a timeout returned bygetRequestTimeout()
. SeeTarantoolRequestRetryPolicies.InfiniteRetryPolicy
for example of implementation.- Type Parameters:
T
- operation result type- Parameters:
operation
- supplier for the operation to perform. Must return a new operation instanceexecutor
- executor in which the retry callbacks will be scheduled- Returns:
CompletableFuture
with the same type as the operation result type
-
-