Configuration

class Configuration

Contains HttpRequestRetry configurations settings.

Constructors

Link copied to clipboard
fun Configuration()

Functions

Link copied to clipboard
fun constantDelay(millis: Long = 1000, randomizationMs: Long = 1000, respectRetryAfterHeader: Boolean = true)

Specifies a constant delay between retries. This delay equals to millis + [0..randomizationMs] milliseconds.

Link copied to clipboard
fun delay(block: suspend (Long) -> Unit)

A function that waits for the specified amount of milliseconds. Uses kotlinx.coroutines.delay by default. Useful for tests.

Link copied to clipboard
fun delayMillis(respectRetryAfterHeader: Boolean = true, block: HttpRequestRetry.DelayContext.(retry: Int) -> Long)

Specifies delay logic for retries. The block accepts the number of retries and should return the number of milliseconds to wait before retrying.

Link copied to clipboard
fun exponentialDelay(base: Double = 2.0, maxDelayMs: Long = 60000, randomizationMs: Long = 1000, respectRetryAfterHeader: Boolean = true)

Specifies an exponential delay between retries, which is calculated using the Exponential backoff algorithm. This delay equals to base ^ retryCount * 1000 + [0..randomizationMs]

Link copied to clipboard

Modifies a request before retrying.

Link copied to clipboard
fun noRetry()

Disables retry.

Link copied to clipboard
fun retryIf(maxRetries: Int = -1, block: HttpRequestRetry.ShouldRetryContext.(HttpRequest, HttpResponse) -> Boolean)

Specifies retry logic for a response. The block accepts HttpRequest and HttpResponse and should return true if this request should be retried.

Link copied to clipboard
fun retryOnException(maxRetries: Int = -1)

Enables retrying a request if an exception is thrown during the HttpSend phase and specifies the number of retries.

Link copied to clipboard
fun retryOnExceptionIf(maxRetries: Int = -1, block: HttpRequestRetry.ShouldRetryContext.(HttpRequestBuilder, Throwable) -> Boolean)

Specifies retry logic for failed requests. The block accepts HttpRequestBuilder and Throwable and should return true if this request should be retried.

Link copied to clipboard
fun retryOnExceptionOrServerErrors(maxRetries: Int = -1)

Enables retrying a request if an exception is thrown during the HttpSend phase or a 5xx response is received and specifies the number of retries.

Link copied to clipboard
fun retryOnServerErrors(maxRetries: Int = -1)

Enables retrying a request if a 5xx response is received from a server and specifies the number of retries.

Properties

Link copied to clipboard
var maxRetries: Int = 0

The maximum amount of retries to perform for a request.