Tinkex.Config (Tinkex v0.1.17)

View Source

Client configuration for the Tinkex SDK.

Instances of this struct are passed through every API call to support multi-tenant usage (different API keys, base URLs, timeouts, and retry policies within the same BEAM VM). Construction is the only place where we consult Application.get_env/3; the request hot path only works with the struct that callers provide.

Summary

Functions

Return BEAM-conservative default max_retries (2).

Return BEAM-conservative default timeout (120s).

Build a config struct using runtime options + application/env defaults.

Return Python SDK parity max_retries (10).

Return Python SDK parity timeout (60s).

Validate an existing config struct.

Types

proxy()

@type proxy() ::
  {:http | :https, host :: String.t(), port :: 1..65535, opts :: keyword()}
  | nil

t()

@type t() :: %Tinkex.Config{
  api_key: String.t(),
  base_url: String.t(),
  cf_access_client_id: String.t() | nil,
  cf_access_client_secret: String.t() | nil,
  default_headers: map(),
  default_query: map(),
  dump_headers?: boolean(),
  feature_gates: [String.t()] | nil,
  http_client: module(),
  http_pool: atom(),
  log_level: :debug | :info | :warn | :error | nil,
  max_retries: non_neg_integer(),
  proxy: proxy(),
  proxy_headers: [{String.t(), String.t()}],
  tags: [String.t()] | nil,
  telemetry_enabled?: boolean(),
  timeout: pos_integer(),
  user_metadata: map() | nil
}

Functions

default_max_retries()

@spec default_max_retries() :: non_neg_integer()

Return BEAM-conservative default max_retries (2).

default_timeout()

@spec default_timeout() :: pos_integer()

Return BEAM-conservative default timeout (120s).

new(opts \\ [])

@spec new(keyword()) :: t()

Build a config struct using runtime options + application/env defaults.

max_retries is the number of additional attempts after the initial request. With the default of 2, the SDK will perform up to three total attempts.

Parity Mode

By default, Tinkex uses BEAM-conservative defaults:

  • timeout: 120_000 (2 minutes)
  • max_retries: 2 (3 total attempts)

To match Python SDK defaults, enable parity mode:

# Via options
config = Tinkex.Config.new(parity_mode: :python)

# Via application config
config :tinkex, parity_mode: :python

# Via environment variable
export TINKEX_PARITY=python

Python parity mode sets:

  • timeout: 60_000 (1 minute)
  • max_retries: 10 (11 total attempts)

Explicit timeout/max_retries options always override parity defaults.

python_max_retries()

@spec python_max_retries() :: non_neg_integer()

Return Python SDK parity max_retries (10).

python_timeout()

@spec python_timeout() :: pos_integer()

Return Python SDK parity timeout (60s).

validate!(config)

@spec validate!(t()) :: t()

Validate an existing config struct.