RetryPolicy

data class RetryPolicy(val maxRetries: Int = 2, val initialBackoff: Duration = 500.milliseconds, val maxBackoff: Duration = 5.seconds, val jitter: Double = 0.25, val retryStatuses: Set<Int> = setOf(408, 429) + (500..599), val respectRetryAfter: Boolean = true, val maxRetryAfter: Duration = 60.seconds, val retryOnConnectionError: Boolean = true, val retryOnTimeout: Boolean = true)(source)

When and how failed requests are retried. The defaults match the official Python and JS SDKs: two retries, 0.5 s backoff doubling to a 5 s cap with up to 25% subtracted as jitter, and server retry-after-ms / Retry-After hints honored up to maxRetryAfter.

Constructors

Link copied to clipboard
constructor(maxRetries: Int = 2, initialBackoff: Duration = 500.milliseconds, maxBackoff: Duration = 5.seconds, jitter: Double = 0.25, retryStatuses: Set<Int> = setOf(408, 429) + (500..599), respectRetryAfter: Boolean = true, maxRetryAfter: Duration = 60.seconds, retryOnConnectionError: Boolean = true, retryOnTimeout: Boolean = true)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun backoff(retryNumber: Int, random: Double): Duration

The delay before retry number retryNumber (1-based): min(initial * 2^(n-1), max), reduced by jitter * random of itself. random is a value in 0.0..1.0.