Package com.fauna.client
Class RetryHandler<T>
- java.lang.Object
-
- com.fauna.client.RetryHandler<T>
-
- Type Parameters:
T
- The return type for a successful response.
public final class RetryHandler<T> extends java.lang.Object
A retry handler controls the retries for a particular request.
-
-
Constructor Summary
Constructors Constructor Description RetryHandler(RetryStrategy strategy, java.util.logging.Logger logger)
Constructs a new retry handler instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<T>
delayRequest(java.util.function.Supplier<java.util.concurrent.CompletableFuture<T>> action, int delayMillis)
Delays the request execution by a specified delay in milliseconds.java.util.concurrent.CompletableFuture<T>
execute(java.util.function.Supplier<java.util.concurrent.CompletableFuture<T>> action)
Executes an action with retry logic based on the retry strategy.static boolean
isRetryable(java.lang.Throwable exc)
Checks if an exception is retryable.java.util.concurrent.CompletableFuture<T>
rethrow(java.lang.Throwable throwable)
Rethrows a throwable as a FaunaException.
-
-
-
Constructor Detail
-
RetryHandler
public RetryHandler(RetryStrategy strategy, java.util.logging.Logger logger)
Constructs a new retry handler instance.- Parameters:
strategy
- The retry strategy to use.logger
- The logger used to log retry details.
-
-
Method Detail
-
delayRequest
public java.util.concurrent.CompletableFuture<T> delayRequest(java.util.function.Supplier<java.util.concurrent.CompletableFuture<T>> action, int delayMillis)
Delays the request execution by a specified delay in milliseconds.- Parameters:
action
- The action to be executed.delayMillis
- The delay in milliseconds before executing the action.- Returns:
- A CompletableFuture representing the result of the action.
-
isRetryable
public static boolean isRetryable(java.lang.Throwable exc)
Checks if an exception is retryable.- Parameters:
exc
- The exception to check.- Returns:
- True if the exception or its cause is retryable.
-
rethrow
public java.util.concurrent.CompletableFuture<T> rethrow(java.lang.Throwable throwable)
Rethrows a throwable as a FaunaException.- Parameters:
throwable
- The throwable to be rethrown.- Returns:
- A failed CompletableFuture containing the throwable.
-
execute
public java.util.concurrent.CompletableFuture<T> execute(java.util.function.Supplier<java.util.concurrent.CompletableFuture<T>> action)
Executes an action with retry logic based on the retry strategy.- Parameters:
action
- The action to execute.- Returns:
- A CompletableFuture representing the result of the action.
-
-