public interface Backoff extends Function<IterationContext<?>,BackoffDelay>
Modifier and Type | Field and Description |
---|---|
static Backoff |
ZERO_BACKOFF |
Modifier and Type | Method and Description |
---|---|
static Backoff |
exponential(Duration firstBackoff,
Duration maxBackoff,
int factor,
boolean basedOnPreviousValue)
Backoff function with exponential backoff delay.
|
static Backoff |
fixed(Duration backoffInterval)
Backoff function with fixed backoff delay
|
static Backoff |
zero()
Backoff function with no backoff delay
|
static final Backoff ZERO_BACKOFF
static Backoff zero()
static Backoff fixed(Duration backoffInterval)
backoffInterval
- backoff intervalstatic Backoff exponential(Duration firstBackoff, @Nullable 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 duration, capped to Long.MAX_VALUE
millisecondsfactor
- The multiplicand for calculating backoffbasedOnPreviousValue
- If true, calculation is based on previous value which may
be a backoff with jitter applied