Interface BackoffStrategy
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Strategy for computing delay between retry attempts.
- Since:
- 5.4.0
- Author:
- Stefan Dragisic
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BackoffStrategyBackoff strategy that applies no delay between retry attempts. -
Method Summary
Modifier and TypeMethodDescriptiondelay(int attempt) Computes the delay before the given retry attempt.static BackoffStrategyexponential(Duration base, Duration max) Exponential backoff:min(base * 2^(attempt-1), max), clamped tomaxat large attempt counts so the factor/multiply can never overflow, go negative, or wrap.static BackoffStrategyFixed delay between every retry attempt.static BackoffStrategyLinear backoff:baseDelay * attempt.
-
Field Details
-
NONE
Backoff strategy that applies no delay between retry attempts.
-
-
Method Details
-
fixed
Fixed delay between every retry attempt.- Parameters:
delay- constant delay duration.- Returns:
- a backoff strategy with fixed delay.
-
linear
Linear backoff:baseDelay * attempt.- Parameters:
baseDelay- base delay multiplied by the attempt number.- Returns:
- a backoff strategy with linearly increasing delay.
-
exponential
Exponential backoff:min(base * 2^(attempt-1), max), clamped tomaxat large attempt counts so the factor/multiply can never overflow, go negative, or wrap.- Parameters:
base- base delay for the first attempt.max- maximum delay cap.- Returns:
- a backoff strategy with exponentially increasing delay.
-
delay
Computes the delay before the given retry attempt.- Parameters:
attempt- the retry attempt number (1-based).- Returns:
- the duration to wait before executing the attempt.
-