Foundation.Retry (foundation v0.2.1)

Copy Markdown View Source

Generic retry orchestration with configurable policies.

Summary

Functions

Check whether progress or elapsed-time limits have been exceeded.

Record progress to reset the progress timeout window.

Run a function with retry semantics.

Decide whether to retry based on the policy and current result.

Types

retry_result()

@type retry_result() ::
  {:retry, non_neg_integer(), Foundation.Retry.State.t()}
  | {:halt, term(), Foundation.Retry.State.t()}

Functions

check_timeouts(state, policy, opts \\ [])

@spec check_timeouts(
  Foundation.Retry.State.t(),
  Foundation.Retry.Policy.t(),
  keyword()
) ::
  :ok | {:error, atom()}

Check whether progress or elapsed-time limits have been exceeded.

record_progress(state, opts \\ [])

@spec record_progress(
  Foundation.Retry.State.t(),
  keyword()
) :: Foundation.Retry.State.t()

Record progress to reset the progress timeout window.

run(fun, policy, opts \\ [])

Run a function with retry semantics.

step(state, policy, result, opts \\ [])

Decide whether to retry based on the policy and current result.