java.lang.Object
com.agentforge4j.util.retry.DecorrelatedJitter
Decorrelated-jitter backoff delay computation, shared by every retry loop in the codebase that
needs to space out attempts against a transient failure.
The algorithm draws the next delay uniformly from [base, min(cap, 3 * lastDelay)),
which spreads out concurrent retriers better than plain exponential backoff while still growing
the delay across attempts. This class only computes the delay; callers own their own retry loop
(attempt counting, which failures are retryable, whether to sleep at all) since that differs by
caller.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longnextDelayMillis(long baseMillis, long lastDelayMillis, long capMillis) Computes the next decorrelated-jitter delay.
-
Method Details
-
nextDelayMillis
public static long nextDelayMillis(long baseMillis, long lastDelayMillis, long capMillis) Computes the next decorrelated-jitter delay.- Parameters:
baseMillis- the minimum delay (and the floor of every draw); non-negativelastDelayMillis- the delay used for the previous attempt (or the base, for the first retry); non-negativecapMillis- the maximum delay this call may return- Returns:
- a delay in milliseconds, at least
baseMillisand at mostcapMillis
-