LangEx.Graph.RetryPolicy (LangEx v0.11.3)

Copy Markdown View Source

Retry configuration for the retry: node option.

Attempts retry on exceptions only — {:error, term} return values are ordinary node results and are never retried. Delays grow exponentially and are capped:

delay = min(max_interval_ms, initial_interval_ms * backoff_factor^(attempt - 1))

With jitter: true (the default) up to 10% random delay is added so simultaneous retries do not stampede a recovering dependency.

Options

  • :max_attempts — total attempts including the first (default 3)
  • :initial_interval_ms — delay before the first retry (default 100); :backoff_ms is accepted as a legacy alias
  • :backoff_factor — exponential growth factor (default 2.0)
  • :max_interval_ms — delay ceiling (default 30_000)
  • :jitter — add up to 10% random delay (default true)
  • :retryable?(exception -> boolean) filter (default: retry all)

Summary

Functions

Delay in milliseconds before retrying after the given failed attempt.

Normalizes the retry: node option into a policy map.

Types

t()

@type t() :: %{
  max_attempts: pos_integer(),
  initial_interval_ms: non_neg_integer(),
  backoff_factor: number(),
  max_interval_ms: pos_integer(),
  jitter: boolean(),
  retryable?: (Exception.t() -> boolean())
}

Functions

delay_ms(policy, attempt)

@spec delay_ms(t(), pos_integer()) :: non_neg_integer()

Delay in milliseconds before retrying after the given failed attempt.

normalize(retry_opts)

@spec normalize(nil | true | keyword()) :: t() | nil

Normalizes the retry: node option into a policy map.