Raxol.Payments.Poll (Raxol Payments v0.2.0)

Copy Markdown View Source

Shared status-polling engine for cross-chain settlement.

Settlement is observed only by polling (Riddler has no client-facing push), so to see a sub-three-second settlement the loop polls fast inside a short budget window, then widens for the long tail to avoid hammering the service:

  • For the first :budget_ms, poll every :fast_interval_ms.
  • After that, poll every :slow_interval_ms until :timeout_ms.
  • An HTTP 429 is treated as a transient backoff, not a failure.

run/3 returns {:ok, status, elapsed_ms} when terminal? first holds, so the caller can classify the settlement as within-budget or slow. It returns {:error, :timeout} at the ceiling and {:error, reason} on a non-retryable fetch error.

Summary

Functions

Default budget window in milliseconds.

Poll fetch until terminal? holds, the deadline passes, or a fetch fails.

Types

result()

@type result() :: {:ok, term(), non_neg_integer()} | {:error, term()}

Functions

default_budget_ms()

@spec default_budget_ms() :: pos_integer()

Default budget window in milliseconds.

run(fetch, terminal?, opts \\ [])

@spec run((-> {:ok, term()} | {:error, term()}), (term() -> boolean()), keyword()) ::
  result()

Poll fetch until terminal? holds, the deadline passes, or a fetch fails.

fetch is a 0-arity function returning {:ok, status} | {:error, reason}; terminal? takes a status and returns a boolean.