KresilRetryPlugin

A plugin that enables the client to retry failed requests based on the Kresil Retry mechanism configuration and the HttpRequestRetry plugin provided by Ktor. Configuration can be done globally when installing the plugin, and on a per-request basis with the kRetry function.

Examples of usage:

// use predefined retry policies
install(KresilRetryPlugin)

// use custom policies
install(KresilRetryPlugin) {
maxRetries = 5
retryOnException { it is NetworkError }
// retryOnTimeout()
constantDelay(2.seconds)
// noDelay()
// customDelay { attempt, context -> ... }
modifyRequestOnRetry { request, attempt ->
request.headers.append("X_RETRY_COUNT", "$attempt")
}
}

// disable retry for a specific request
client.post {
kRetry(disable = true)
}

See also