Huginn.Clickhouse.Retry (Huginn v0.4.0)

View Source

Retries transport-level gRPC failures with exponential backoff.

Only transient failures are retried — connection errors and a small set of retryable gRPC statuses (UNAVAILABLE, DEADLINE_EXCEEDED). ClickHouse query errors (a returned Exception with a non-zero code) are not transient and are returned to the caller unchanged.

Summary

Functions

Returns true when reason represents a transient transport failure.

Runs fun and retries on transient errors.

Functions

transient?(reason)

@spec transient?(term()) :: boolean()

Returns true when reason represents a transient transport failure.

with_retry(fun, opts \\ [])

@spec with_retry(
  (-> {:ok, term()} | {:error, term()}),
  keyword()
) :: {:ok, term()} | {:error, term()}

Runs fun and retries on transient errors.

fun is a 0-arity function returning {:ok, term} or {:error, reason}.

Options

  • :retries - maximum number of additional attempts after the first (default: 0, i.e. no retries — preserves non-retrying behavior).
  • :retry_backoff - base backoff in milliseconds; the delay for attempt n is retry_backoff * 2 ** (n - 1) (default: 100).