ResilientPlugin

A Ktor HTTP client plugin that applies a com.santimattius.resilient.ResilientPolicy transparently to every outgoing HTTP request via the Send hook.

Usage — Bring-Your-Own policy

val client = HttpClient {
install(ResilientPlugin) {
policy = myExistingPolicy
}
}

Usage — Inline DSL

val client = HttpClient {
install(ResilientPlugin) {
scope = appScope.asResilientScope()
retry { maxAttempts = 3 }
shouldRetryOnStatus = { it.value >= 500 }
}
}

Idempotency gate

By default (retryOnlyIdempotent = true), POST and PATCH requests bypass the policy entirely, preserving at-most-once semantics. See ResilientPluginConfig.retryOnlyIdempotent and ADR-3.

Policy lifecycle

  • BYO policy: the plugin does NOT close the user-provided policy on client.close().

  • Inline DSL: the plugin owns the policy and closes it via onClose { }.