Column.RateLimit (Column v1.0.0)

Copy Markdown View Source

Rate limit information parsed from Column API response headers.

Column includes rate limit headers on API responses. This struct captures that information for observability and backoff decisions.

Headers parsed

  • x-ratelimit-limit — Maximum requests allowed in the window
  • x-ratelimit-remaining — Remaining requests in current window
  • x-ratelimit-reset — Unix timestamp when the window resets
  • retry-after — Seconds to wait before retrying (on 429 responses)

Usage

case Column.ACH.create(%{...}) do
  {:ok, result} -> result
  {:error, %Column.Error{status: 429, raw: raw}} ->
    info = Column.RateLimit.from_error_raw(raw)
    Process.sleep(info.retry_after_ms || 1_000)
    # retry...
end

Summary

Functions

Returns true if the rate limit window is exhausted.

Build from error raw body (when you only have the error struct).

Parse rate limit info from Req-style response headers (a map of lists).

Milliseconds to wait before the rate limit window resets.

Types

headers()

@type headers() :: %{optional(String.t()) => [String.t()]}

t()

@type t() :: %Column.RateLimit{
  limit: non_neg_integer() | nil,
  remaining: non_neg_integer() | nil,
  reset_at: DateTime.t() | nil,
  retry_after_ms: non_neg_integer() | nil
}

Functions

exhausted?(rate_limit)

@spec exhausted?(t()) :: boolean()

Returns true if the rate limit window is exhausted.

from_error_raw(arg1)

@spec from_error_raw(map() | nil) :: t()

Build from error raw body (when you only have the error struct).

from_headers(headers)

@spec from_headers(headers()) :: t()

Parse rate limit info from Req-style response headers (a map of lists).

ms_until_reset(rate_limit)

@spec ms_until_reset(t()) :: non_neg_integer() | nil

Milliseconds to wait before the rate limit window resets.