@ThreadSafe public interface BackoffStrategy
| Modifier and Type | Method and Description |
|---|---|
Duration |
computeDelay(int attempt)
Compute the amount of time to wait before the provided attempt number is executed.
|
static BackoffStrategy |
exponentialDelay(Duration baseDelay,
Duration maxDelay)
Wait for a random period of time between 0ms and an exponentially increasing amount of time between each subsequent attempt
of the same call.
|
static BackoffStrategy |
exponentialDelayHalfJitter(Duration baseDelay,
Duration maxDelay)
Wait for a random period of time with an upper bound of exponentially increasing amount of time between each subsequent
attempt of the same call and a lower bound of half the amount of the computed exponential delay.
|
static BackoffStrategy |
exponentialDelayWithoutJitter(Duration baseDelay,
Duration maxDelay)
Wait for an exponentially increasing amount of time between each subsequent attempt of the same call.
|
static BackoffStrategy |
fixedDelay(Duration delay)
Wait for a random period of time between 0ms and the provided delay.
|
static BackoffStrategy |
fixedDelayWithoutJitter(Duration delay)
Wait for a period of time equal to the provided delay.
|
static BackoffStrategy |
retryImmediately()
Do not back off: retry immediately.
|
Duration computeDelay(int attempt)
attempt - The attempt to compute the delay for, starting at one.IllegalArgumentException - If the given attempt is less or equal to zero.static BackoffStrategy retryImmediately()
static BackoffStrategy fixedDelay(Duration delay)
static BackoffStrategy fixedDelayWithoutJitter(Duration delay)
static BackoffStrategy exponentialDelay(Duration baseDelay, Duration maxDelay)
Specifically, the first attempt waits 0ms, and each subsequent attempt waits between
0ms and min(maxDelay, baseDelay * (1 << (attempt - 2))).
static BackoffStrategy exponentialDelayHalfJitter(Duration baseDelay, Duration maxDelay)
Specifically, the first attempt waits 0ms, and each subsequent attempt waits between
min(maxDelay, baseDelay * (1 << (attempt - 2))) / 2 and min(maxDelay, baseDelay * (1 << (attempt - 2))) +
1.
static BackoffStrategy exponentialDelayWithoutJitter(Duration baseDelay, Duration maxDelay)
Specifically, the first attempt waits 0ms, and each subsequent attempt waits for
min(maxDelay, baseDelay * (1 << (attempt - 2))).
Copyright © 2026. All rights reserved.