Generic polling loop with backoff and timeout controls.
Summary
Functions
Run a polling loop in a Task.
Await a polling task, converting exits into error tuples.
Run a polling loop until completion, error, timeout, or max attempts.
Types
@type backoff() :: :none | Foundation.Backoff.Policy.t() | {:exponential, pos_integer(), pos_integer()} | (non_neg_integer() -> non_neg_integer())
@type step_result() :: {:ok, term()} | {:retry, term()} | {:retry, term(), non_neg_integer()} | {:error, term()} | :retry
Functions
@spec async( (non_neg_integer() -> step_result()), keyword() ) :: Task.t()
Run a polling loop in a Task.
Await a polling task, converting exits into error tuples.
@spec run( (non_neg_integer() -> step_result()), keyword() ) :: {:ok, term()} | {:error, term()}
Run a polling loop until completion, error, timeout, or max attempts.
The step_fun receives the current attempt (0-based).