Interface Jitter
public interface Jitter
Strategy interface for applying jitter to exponential backoff calculations.
- Author:
- Bruno Garcia, Rafael Pavarini, Tomaz Fernandes
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classContext for jitter calculations. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final JitterFull jitter strategy - returns a random value between 0 and the original timeout.static final JitterHalf jitter strategy - returns a value uniformly between ceil(timeout/2) and timeout.static final JitterNo jitter strategy - returns the original timeout value. -
Method Summary
Modifier and TypeMethodDescriptionintapplyJitter(Jitter.Context context) Apply jitter to the calculated timeout value.
-
Field Details
-
NONE
No jitter strategy - returns the original timeout value. The original timeout value is expected to be valid (greater than 0) as it's validated in the builder. -
FULL
Full jitter strategy - returns a random value between 0 and the original timeout. Ensures the result is at least 1 to avoid invalid timeout values. -
HALF
Half jitter strategy - returns a value uniformly between ceil(timeout/2) and timeout. Ensures the result is at least 1 to avoid invalid timeout values.
-
-
Method Details
-
applyJitter
Apply jitter to the calculated timeout value.- Parameters:
context- the jitter context containing timeout and random supplier- Returns:
- the timeout value with jitter applied
-