Interface BackoffStrategy
- All Known Implementing Classes:
ExponentialDelayWithHalfJitter,ExponentialDelayWithJitter,ExponentialDelayWithoutJitter,FixedDelayWithJitter,FixedDelayWithoutJitter,Immediately,LegacyToNonLegacyAdapter
Determines how long to wait before each execution attempt.
-
Method Summary
Modifier and TypeMethodDescriptioncomputeDelay(int attempt) Compute the amount of time to wait before the provided attempt number is executed.static BackoffStrategyexponentialDelay(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 BackoffStrategyexponentialDelayHalfJitter(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 BackoffStrategyexponentialDelayWithoutJitter(Duration baseDelay, Duration maxDelay) Wait for an exponentially increasing amount of time between each subsequent attempt of the same call.static BackoffStrategyfixedDelay(Duration delay) Wait for a random period of time between 0ms and the provided delay.static BackoffStrategyfixedDelayWithoutJitter(Duration delay) Wait for a period of time equal to the provided delay.static BackoffStrategyDo not back off: retry immediately.
-
Method Details
-
computeDelay
Compute the amount of time to wait before the provided attempt number is executed.- Parameters:
attempt- The attempt to compute the delay for, starting at one.- Throws:
IllegalArgumentException- If the given attempt is less or equal to zero.
-
retryImmediately
Do not back off: retry immediately. -
fixedDelay
Wait for a random period of time between 0ms and the provided delay. -
fixedDelayWithoutJitter
Wait for a period of time equal to the provided delay. -
exponentialDelay
Wait for a random period of time between 0ms and an exponentially increasing amount of time between each subsequent attempt of the same call.Specifically, the first attempt waits 0ms, and each subsequent attempt waits between 0ms and
min(maxDelay, baseDelay * (1 << (attempt - 2))). -
exponentialDelayHalfJitter
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.Specifically, the first attempt waits 0ms, and each subsequent attempt waits between
min(maxDelay, baseDelay * (1 << (attempt - 2))) / 2andmin(maxDelay, baseDelay * (1 << (attempt - 2))) + 1. -
exponentialDelayWithoutJitter
Wait for an exponentially increasing amount of time between each subsequent attempt of the same call.Specifically, the first attempt waits 0ms, and each subsequent attempt waits for
min(maxDelay, baseDelay * (1 << (attempt - 2))).
-