Coffrify. Runtime. Retry
(Coffrify v0.9.0)
View Source
Pluggable retry policies used by Coffrify.Client and exposed for user
code.
Built-in implementations:
Coffrify.Runtime.Retry.ExponentialBackoffCoffrify.Runtime.Retry.DecorrelatedJitterCoffrify.Runtime.Retry.FibonacciBackoffCoffrify.Runtime.Retry.FixedDelay
A policy is any term whose module implements the Policy behaviour. The
client calls Policy.next/3 with the current attempt number and the
request context (status, error reason, parsed Retry-After).
Summary
Functions
Apply jitter symmetrically around base by the given fraction.
Invoke a policy. policy is any struct implementing the Policy
behaviour.
Parse an HTTP Retry-After header (seconds OR HTTP-date) into ms.
Returns nil when the header is missing or malformed.
Types
@type context() :: %{ optional(:status) => non_neg_integer(), optional(:error_reason) => atom() | term(), optional(:retry_after_ms) => non_neg_integer() | nil }
Per-request context handed to the policy.
@type decision() :: %{should_retry: boolean(), delay_ms: non_neg_integer()}
Decision returned by a retry policy.
Functions
@spec jitter(non_neg_integer(), float()) :: non_neg_integer()
Apply jitter symmetrically around base by the given fraction.
@spec next(struct(), non_neg_integer(), context()) :: decision()
Invoke a policy. policy is any struct implementing the Policy
behaviour.
@spec parse_retry_after(String.t() | nil) :: non_neg_integer() | nil
Parse an HTTP Retry-After header (seconds OR HTTP-date) into ms.
Returns nil when the header is missing or malformed.