public interface Backoff extends java.util.function.Function<IterationContext<?>,BackoffDelay>
Modifier and Type | Field and Description |
---|---|
static Backoff |
ZERO_BACKOFF |
Modifier and Type | Method and Description |
---|---|
static Backoff |
exponential(java.time.Duration firstBackoff,
java.time.Duration maxBackoff,
int factor,
boolean basedOnPreviousValue)
Backoff function with exponential backoff delay.
|
static Backoff |
fixed(java.time.Duration backoffInterval)
Backoff function with fixed backoff delay
|
static Backoff |
zero()
Backoff function with no backoff delay
|
andThen, apply, compose, identity
static final Backoff ZERO_BACKOFF
static Backoff zero()
static Backoff fixed(java.time.Duration backoffInterval)
backoffInterval
- backoff intervalstatic Backoff exponential(java.time.Duration firstBackoff, @Nullable java.time.Duration maxBackoff, int factor, boolean basedOnPreviousValue)
firstBackoff * (factor ** n)
where n is the iteration. If
maxBackoff
is not null, the maximum backoff applied will be limited to
maxBackoff
.
If basedOnPreviousValue
is true, backoff will be calculated using
prevBackoff * factor
. When backoffs are combined with Jitter
, this
value will be different from the actual exponential value for the iteration.
firstBackoff
- First backoff durationmaxBackoff
- Maximum backoff durationfactor
- The multiplicand for calculating backoffbasedOnPreviousValue
- If true, calculation is based on previous value which may
be a backoff with jitter applied