RetryPluginConfigBuilder

Constructors

Link copied to clipboard
constructor(baseConfig: RetryPluginConfig)

Properties

Link copied to clipboard
open override val baseConfig: RetryPluginConfig
Link copied to clipboard

The maximum number of attempts (including the initial call as the first attempt).

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

Functions

Link copied to clipboard
private fun aggregateRetryPredicates(throwable: Throwable): Boolean

Aggregates all configured retry predicates to determine if the HTTP call should be retried based on the caught throwable.

Link copied to clipboard
open override fun build(): RetryPluginConfig
Link copied to clipboard
fun constantDelay(duration: Duration, randomizationFactor: Double = 0.0)

Configures the retry delay strategy to use a constant delay. The delay between retries is calculated using the formula:

Link copied to clipboard
fun customDelay(delayStrategy: RetryDelayStrategy)

Configures the retry delay strategy to use a custom delay strategy.

Link copied to clipboard

Configures the retry delay strategy to use a custom delay provider. In contrast to customDelay, this method enables caller control over the delay provider (which is the kotlinx.coroutines.delay by default) and optional additional state between retries. See RetryCtxDelayProvider for more information and examples of usage.

Link copied to clipboard

Disables the retry plugin.

Link copied to clipboard
fun exponentialDelay(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 2.0, maxDelay: Duration = 1.minutes, randomizationFactor: Double = 0.0)

Configures the retry delay strategy to use the exponential backoff algorithm. The delay between retries is calculated using the formula: The algorithm is based on the formula:

Link copied to clipboard
fun linearDelay(initialDelay: Duration = 500L.milliseconds, multiplier: Double = 1.0, maxDelay: Duration = 1.minutes, randomizationFactor: Double = 0.0)

Configures the retry delay strategy to use the linear backoff algorithm. The delay between retries is calculated using the formula:

Link copied to clipboard
fun modifyRequestOnRetry(block: (builder: HttpRequestBuilder, attempt: Int) -> Unit)

Modifies the request between retries, before it is sent. The block receives the HttpRequestBuilder and the current retry attempt as arguments.

Link copied to clipboard
fun noDelay()

Configures the retry delay strategy to have no delay between retries (i.e., retries are immediate and do not use any custom delay provider.

Link copied to clipboard
fun retryOnCall(block: (request: HttpRequest, response: HttpResponse) -> Boolean)

Configures a predicate to determine if an HTTP call should be retried based on the respective request and response.

Link copied to clipboard

Configures the retry predicate, used to determine if, based on the caught throwable, the underlying request should be retried.

Link copied to clipboard

Retries the HTTP call if the response status code is in the range: 500-599.

Link copied to clipboard

Retries the HTTP call if the request method is idempotent (i.e., the intended effect on the server of multiple identical requests with that method is the same as the effect for a single such request) and the response status code is in the specified range. Idempotent methods supported by Ktor are: GET, HEAD, OPTIONS, PUT, DELETE.

Link copied to clipboard

Retries the HTTP call if the exception thrown is a timeout exception. See HttpTimeout plugin for more information on possible timeout exceptions. If this method is used, HttpTimeout plugin should be installed after this plugin.