GoCardlessClient.HTTP.Client (GoCardlessClient v2.0.0)

Copy Markdown View Source

Resilient HTTP client over Finch with retries, jitter backoff, and Telemetry.

  • Exponential backoff with full jitter on 429 / 5xx responses
  • Respects Retry-After header
  • Emits [:gocardless, :request, :start | :stop | :exception] Telemetry events

  • Tracks X-RateLimit-* headers via GoCardlessClient.HTTP.RateLimiter

Summary

Functions

Executes an API request with automatic retries and backoff.

Types

method()

@type method() :: :get | :post | :put | :patch | :delete

req_state()

@type req_state() :: %{
  config: GoCardlessClient.Config.t(),
  method: method(),
  url: String.t(),
  headers: [{String.t(), String.t()}],
  body: binary() | nil,
  remaining: non_neg_integer(),
  attempt: non_neg_integer()
}

response()

@type response() ::
  {:ok, map() | list() | nil}
  | {:error, GoCardlessClient.APIError.t() | GoCardlessClient.Error.t()}

Functions

request(config, method, path, opts \\ [])

@spec request(GoCardlessClient.Config.t(), method(), String.t(), keyword()) ::
  response()

Executes an API request with automatic retries and backoff.

Options

  • :body — request body map (JSON-encoded before sending)
  • :idempotency_key — sets Idempotency-Key header
  • :request_id — sets X-Request-ID correlation header
  • :access_token — overrides bearer token for this request only
  • :signer — a GoCardlessClient.Signing struct for request signing