RetryPolicy

@Serializable
sealed class RetryPolicy

Defines how a failed task should be retried.

  • None: No retry. Task fails immediately on error.

  • Linear: Retry with a fixed delay between attempts.

  • Exponential: Retry with exponentially increasing delay. Formula: delay = initialDelayMillis × 2^retryCount

Example:

retryPolicy = RetryPolicy.Exponential(initialDelayMillis = 5_000)
// Attempt 0: immediate
// Attempt 1: 5s
// Attempt 2: 10s
// Attempt 3: 20s
// ...

Inheritors

Types

Link copied to clipboard
@Serializable
data class Exponential(val initialDelayMillis: Long, val maxRetries: Int = Int.MAX_VALUE) : RetryPolicy

Retry with exponentially increasing delay. delay(n) = initialDelayMillis × 2^n

Link copied to clipboard
@Serializable
data class Linear(val delayMillis: Long) : RetryPolicy

Retry with a fixed delay between each attempt.

Link copied to clipboard
@Serializable
data object None : RetryPolicy

No retry on failure.