java.lang.Object
de.cuioss.http.client.retry.ExponentialBackoffRetryStrategy
- All Implemented Interfaces:
RetryStrategy
Exponential backoff retry strategy with jitter to prevent thundering herd.
Algorithm based on AWS Architecture Blog recommendations: - Base delay starts at initialDelay - Each retry multiplies by backoffMultiplier - Random jitter applied: delay * (1 ± jitterFactor) - Maximum delay capped at maxDelay - Total attempts limited by maxAttempts
The strategy includes intelligent exception classification to determine which exceptions should trigger retries versus immediate failure.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating ExponentialBackoffRetryStrategy instances with custom configuration. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a builder for configuring the exponential backoff strategy.<T> CompletableFuture<HttpResultObject<T>> execute(HttpOperation<T> operation, RetryContext context) Executes the given HTTP operation with retry logic using virtual threads and async execution.
-
Method Details
-
execute
public <T> CompletableFuture<HttpResultObject<T>> execute(HttpOperation<T> operation, RetryContext context) Description copied from interface:RetryStrategyExecutes the given HTTP operation with retry logic using virtual threads and async execution.This method runs operations on virtual threads with non-blocking delays between retry attempts. The implementation uses
CompletableFuture.delayedExecutor()with virtual thread executors to provide efficient, scalable retry operations without blocking threads during delays.- Specified by:
executein interfaceRetryStrategy- Type Parameters:
T- the type of result returned by the operation- Parameters:
operation- the HTTP operation to retrycontext- retry context with operation name and attempt info- Returns:
- CompletableFuture containing HttpResultObject with result and comprehensive error/retry information
-
builder
Creates a builder for configuring the exponential backoff strategy.- Returns:
- a new builder instance with default values
-