Hcs.Plug.Retry

hcs · API reference

Retry plug with configurable backoff.

Retries failed requests (5xx or exceptions) with backoff. Only retries idempotent methods (GET, HEAD, PUT, DELETE, OPTIONS).

module Backoff : sig ... end

Backoff strategies

type config = {
  max_attempts : int;
  backoff : int -> float; (* attempt -> delay in seconds *)
  should_retry : exn -> bool; (* Which exceptions to retry *)
}
val default_config : config
val create : 
  clock:[> float Eio.Time.clock_ty ] Eio.Time.clock ->
  ?config:config ->
  ?retry_on:(Response.t -> bool) ->
  unit ->
  (Server.request -> Server.response) ->
  Server.request ->
  Server.response

Create retry plug.

parameter clock Eio clock for sleeping between retries parameter config Retry configuration (default: 3 attempts, exponential backoff) parameter retry_on Predicate for which responses to retry (default: 5xx)