HttpRequestRetry

A plugin that enables the client to retry failed requests. The default retry policy is 3 retries with exponential delay. Typical usages:

// use predefined retry policies
install(HttpRequestRetry) {
retryOnServerErrors(maxRetries = 3)
exponentialDelay()
}

// use custom policies
install(HttpRequestRetry) {
maxRetries = 5
retryIf { request, response -> !response.status.isSuccess() }
retryOnExceptionIf { request, cause -> cause is NetworkError }
delayMillis { retry -> retry * 3000 } // will retry in 3, 6, 9, etc. seconds
modifyRequest { it.headers.append("X_RETRY_COUNT", retryCount.toString()) }
}

Types

Link copied to clipboard

Contains HttpRequestRetry configurations settings.

Link copied to clipboard

A context for HttpRequestRetry.Configuration.delayMillis. Contains a non-null response or cause but not both.

Link copied to clipboard

A context for HttpRequestRetry.Configuration.modifyRequest. Contains a non-null response or cause but not both.

Link copied to clipboard

Data for the HttpRequestRetryEvent event. Contains a non-null response or cause but not both.