Retry

data class Retry(val maxRetries: Int = 5, val backoff: BackoffStrategy = NoBackoff, val retryOnExceptions: List<KClass<out Throwable>> = emptyList()) : RetryPolicy

Enables automatic retries for failed HTTP requests.

Server errors (5xx responses) are always retried up to maxRetries times. Additionally, exceptions matching retryOnExceptions will trigger a retry.

val api = PubgApi(
apiKey = "your-key",
retry = Retry(
maxRetries = 3,
backoff = ExponentialBackoff(baseDelayMs = 500),
retryOnExceptions = listOf(IOException::class),
),
)

Parameters

maxRetries

Maximum number of retry attempts after the initial request fails.

backoff

The delay strategy between retry attempts. Defaults to NoBackoff.

retryOnExceptions

Exception types that should trigger a retry. Only exact type matches or subclasses are considered.

See also

Constructors

Link copied to clipboard
constructor(maxRetries: Int = 5, backoff: BackoffStrategy = NoBackoff, retryOnExceptions: List<KClass<out Throwable>> = emptyList())
constructor(maxRetries: Int = 5, backoff: BackoffStrategy = NoBackoff)

List<KClass<out Throwable>> cannot be exported to JavaScript. This secondary constructor allows JavaScript consumers to instantiate Retry meanwhile retryOnExceptions property is fully ignored.

Properties

Link copied to clipboard
Link copied to clipboard
open override val enabled: Boolean = true

Whether retry logic is active.

Link copied to clipboard
Link copied to clipboard