Marqeta.Config (marqeta v1.0.0)

Copy Markdown View Source

Configuration for the Marqeta client.

Loaded from the :marqeta application environment and validated with NimbleOptions. The validated struct is cached in :persistent_term for zero-overhead repeated reads.

Options

  • :base_url — Base URL of the Marqeta API. Defaults to "https://sandbox-api.marqeta.com/v3".
  • :application_token — Your Marqeta application token. Required.
  • :admin_access_token — Your admin access token. Required.
  • :pool_size — HTTP connection pool size per host. Default: 10.
  • :pool_count — Number of pools per host. Default: 1.
  • :timeout — Request timeout in milliseconds. Default: 30_000.
  • :connect_timeout — Connection timeout in milliseconds. Default: 5_000.
  • :retry_max_attempts — Max retry attempts on transient errors. Default: 3.
  • :retry_base_delay — Base delay for exponential backoff (ms). Default: 500.
  • :retry_max_delay — Maximum retry delay (ms). Default: 10_000.
  • :retry_jitter — Add jitter to retry delays. Default: true.
  • :sandboxtrue when using the sandbox environment. Default: false.
  • :telemetry_prefix — Prefix for telemetry events. Default: [:marqeta].
  • :log_level — Log level for HTTP calls. Default: :info.
  • :custom_headers — Additional headers included in every request.
  • :http_client — HTTP client module (override for testing).

Example

config :marqeta,
  base_url: "https://sandbox-api.marqeta.com/v3",
  application_token: System.fetch_env!("MARQETA_APP_TOKEN"),
  admin_access_token: System.fetch_env!("MARQETA_ADMIN_TOKEN"),
  pool_size: 20,
  timeout: 30_000,
  retry_max_attempts: 3,
  sandbox: true

Summary

Functions

Returns the NimbleOptions schema documentation string.

Returns the current config. Cached in :persistent_term after the first call.

Invalidates the cached config.

Loads configuration from the application environment.

Loads and validates configuration from the application environment.

Types

t()

@type t() :: %Marqeta.Config{
  admin_access_token: String.t(),
  application_token: String.t(),
  base_url: String.t(),
  connect_timeout: pos_integer(),
  custom_headers: [{String.t(), String.t()}],
  http_client: module(),
  log_level: Logger.level(),
  pool_count: pos_integer(),
  pool_size: pos_integer(),
  retry_base_delay: pos_integer(),
  retry_jitter: boolean(),
  retry_max_attempts: non_neg_integer(),
  retry_max_delay: pos_integer(),
  sandbox: boolean(),
  telemetry_prefix: [atom()]
}

Functions

docs()

@spec docs() :: String.t()

Returns the NimbleOptions schema documentation string.

get()

@spec get() :: t()

Returns the current config. Cached in :persistent_term after the first call.

invalidate()

@spec invalidate() :: :ok

Invalidates the cached config.

Call this after updating the application environment at runtime.

load()

@spec load() :: {:ok, t()} | {:error, NimbleOptions.ValidationError.t()}

Loads configuration from the application environment.

Returns {:ok, t()} or {:error, NimbleOptions.ValidationError.t()}.

load!()

@spec load!() :: t()

Loads and validates configuration from the application environment.

Raises NimbleOptions.ValidationError if the configuration is invalid.