ExponentialBackoff class

Exponential backoff with optional jitter.

Delays grow exponentially: initial * (multiplier ^ attempt)

Example without jitter:

ExponentialBackoff(initial: Duration(seconds: 1))
// Delays: 1s, 2s, 4s, 8s, ...

Example with jitter (randomizes 50-100% of calculated delay):

ExponentialBackoff(initial: Duration(seconds: 1), jitter: true)
// Delays: ~0.5-1s, ~1-2s, ~2-4s, ...
Implemented types

Constructors

ExponentialBackoff({required Duration initial, double multiplier = 2.0, Duration? maxDelay, bool jitter = false})
Creates an exponential backoff strategy.

Properties

hashCode → int
The hash code for this object.
no setterinherited
initial → Duration
Initial delay for the first retry.
final
jitter → bool
Whether to add randomization to prevent thundering herd.
final
maxDelay → Duration?
Maximum delay cap (optional).
final
multiplier → double
Multiplier applied for each subsequent attempt (default: 2.0).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

delay(int attempt) → Duration
Calculates the delay before the next retry attempt.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited