ExponentialBackoff

data class ExponentialBackoff(val maxAttempts: Int = 5, val initialDelay: Duration = 2.seconds, val maxDelay: Duration = 60.seconds, val multiplier: Double = 2.0, val jitterFactor: Double = 0.2) : RetryPolicy(source)

Retry with exponential backoff and optional jitter.

Delay formula: min(initialDelay * multiplier^attempt, maxDelay) ± jitter

Constructors

Link copied to clipboard
constructor(maxAttempts: Int = 5, initialDelay: Duration = 2.seconds, maxDelay: Duration = 60.seconds, multiplier: Double = 2.0, jitterFactor: Double = 0.2)

Properties

Link copied to clipboard

delay before first retry

Link copied to clipboard

random jitter factor (0.0 = no jitter, 0.2 = ±20%)

Link copied to clipboard

maximum number of retry attempts

Link copied to clipboard

maximum delay cap

Link copied to clipboard

Maximum number of attempts for this policy.

Link copied to clipboard

backoff multiplier per attempt

Functions

Link copied to clipboard
fun delayForAttempt(attempt: Int): Duration?

Computes the delay before the Nth retry attempt (0-indexed). Returns null if the attempt exceeds maxAttempts.