RetryConfig

data class RetryConfig(val maxRetries: Int = 3, val initialDelayMs: Long = 100, val maxDelayMs: Long = 2000, val retryableStatusCodes: Set<Int> = setOf(500, 502, 503, 504), val retryableExceptions: Set<Class<out Throwable>> = setOf( java.net.ConnectException::class.java, java.net.SocketTimeoutException::class.java, java.io.IOException::class.java, ), val nonRetryableExceptions: List<KClass<out Throwable>> = listOf())

Configuration for retry logic in HTTP operations.

Provides exponential backoff retry strategy for transient failures.

Example Usage:

val resolver = DefaultUniversalResolver(
baseUrl = "https://resolver.example.com",
retryConfig = RetryConfig(
maxRetries = 3,
initialDelayMs = 100,
maxDelayMs = 2000,
retryableStatusCodes = setOf(500, 502, 503, 504)
)
)

Parameters

maxRetries

Maximum number of retry attempts (default: 3)

initialDelayMs

Initial delay before first retry in milliseconds (default: 100)

maxDelayMs

Maximum delay between retries in milliseconds (default: 2000)

retryableStatusCodes

HTTP status codes that should trigger retry (default: 5xx errors)

retryableExceptions

Exception types that should trigger retry (default: network exceptions)

nonRetryableExceptions

Exception types that must never be retried even if they extend a retryable type

Constructors

Link copied to clipboard
constructor(maxRetries: Int = 3, initialDelayMs: Long = 100, maxDelayMs: Long = 2000, retryableStatusCodes: Set<Int> = setOf(500, 502, 503, 504), retryableExceptions: Set<Class<out Throwable>> = setOf( java.net.ConnectException::class.java, java.net.SocketTimeoutException::class.java, java.io.IOException::class.java, ), nonRetryableExceptions: List<KClass<out Throwable>> = listOf())

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

Functions

Link copied to clipboard
suspend fun <T> executeWithRetry(block: suspend () -> T): T

Executes a suspend function with retry logic.