Ollixir.Retry (Ollixir v0.1.1)

Copy Markdown View Source

Retry utilities for transient errors.

Summary

Functions

Execute function with exponential backoff retry.

Types

opts()

@type opts() :: [
  max_attempts: pos_integer(),
  base_delay: pos_integer(),
  max_delay: pos_integer(),
  retry_on: (term() -> boolean())
]

Functions

with_backoff(fun, opts \\ [])

@spec with_backoff((-> {:ok, term()} | {:error, term()}), opts()) ::
  {:ok, term()} | {:error, term()}

Execute function with exponential backoff retry.

Options

  • :max_attempts - Maximum retry attempts (default: 3)
  • :base_delay - Initial delay in ms (default: 1000)
  • :max_delay - Maximum delay in ms (default: 30000)
  • :retry_on - Function to determine if error is retryable