RetryPolicy

sealed class RetryPolicy(source)

Defines a retry strategy for failed message sends.

Use with MessageHandle to implement structured retry behavior:

val policy = RetryPolicy.ExponentialBackoff()
val handle = client.sendText("hello")
handle.retryWith(policy) // suspends until success, non-retryable failure, or max attempts exhausted

Inheritors

Types

Link copied to clipboard
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

Retry with exponential backoff and optional jitter.

Link copied to clipboard
data class Fixed(val maxAttempts: Int = 3, val delay: Duration = 5.seconds) : RetryPolicy

Retry with fixed delay between attempts.

Link copied to clipboard
data object None : RetryPolicy

No retries — fail immediately on first failure.

Properties

Link copied to clipboard

Maximum number of attempts for this policy.

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.