Tinkex.Env (Tinkex v0.3.4)

View Source

Centralized environment variable access for Tinkex.

Naming Convention

  • TINKER_* variables: Shared with Python SDK for cross-language compatibility
  • TINKEX_* variables: Elixir-specific features (pool config, debug tools)
  • CLOUDFLARE_* variables: Third-party service credentials

Normalizes values, applies defaults, and provides helpers for redaction so callers avoid scattered System.get_env/1 usage.

Summary

Functions

Get default headers map from environment.

Get default query params map from environment.

Get custom HTTP client module from environment.

Get HTTP pool name from environment.

Replace a secret with a constant marker.

Get OpenTelemetry propagation setting from environment.

Get parity mode from environment.

Get future polling backoff policy from environment.

Get HTTP pool count from environment.

Get HTTP pool size from environment.

Get proxy configuration from environment.

Get proxy headers from environment.

Redact secrets in a snapshot or map using simple replacement.

Snapshot all known env-driven values in one map.

Types

env_source()

@type env_source() :: :system | %{optional(String.t()) => String.t()}

Functions

api_key(env \\ :system)

@spec api_key(env_source()) :: String.t() | nil

base_url(env \\ :system)

@spec base_url(env_source()) :: String.t() | nil

cf_access_client_id(env \\ :system)

@spec cf_access_client_id(env_source()) :: String.t() | nil

cf_access_client_secret(env \\ :system)

@spec cf_access_client_secret(env_source()) :: String.t() | nil

default_headers(env \\ :system)

@spec default_headers(env_source()) :: map()

Get default headers map from environment.

Set TINKEX_DEFAULT_HEADERS to a JSON object of header name/value pairs.

default_query(env \\ :system)

@spec default_query(env_source()) :: map()

Get default query params map from environment.

Set TINKEX_DEFAULT_QUERY to a JSON object of query name/value pairs.

dump_headers?(env \\ :system)

@spec dump_headers?(env_source()) :: boolean()

feature_gates(env \\ :system)

@spec feature_gates(env_source()) :: [String.t()]

http_client(env \\ :system)

@spec http_client(env_source()) :: module() | nil

Get custom HTTP client module from environment.

Set TINKEX_HTTP_CLIENT to a module name (e.g., Tinkex.API).

http_pool(env \\ :system)

@spec http_pool(env_source()) :: atom() | nil

Get HTTP pool name from environment.

Set TINKEX_HTTP_POOL to an atom name (e.g., Tinkex.HTTP.Pool).

log_level(env \\ :system)

@spec log_level(env_source()) :: :debug | :info | :warn | :error | nil

mask_secret(value)

@spec mask_secret(term()) :: term()

Replace a secret with a constant marker.

otel_propagate(env \\ :system)

@spec otel_propagate(env_source()) :: boolean()

Get OpenTelemetry propagation setting from environment.

Set TINKEX_OTEL_PROPAGATE=true to enable W3C Trace Context propagation. When enabled, outgoing requests will carry traceparent/tracestate headers.

parity_mode(env \\ :system)

@spec parity_mode(env_source()) :: :python | :beam | nil

Get parity mode from environment.

Defaults to Python parity. Set TINKEX_PARITY=beam to use BEAM-conservative defaults (timeout: 120_000, max_retries: 2), or TINKEX_PARITY=python to explicitly select Python SDK defaults (timeout: 60_000, max_retries: 10).

poll_backoff(env \\ :system)

@spec poll_backoff(env_source()) :: :exponential | nil

Get future polling backoff policy from environment.

Set TINKEX_POLL_BACKOFF=exponential (or truthy value) to enable backoff for 408/5xx polling retries. Use TINKEX_POLL_BACKOFF=0 to disable.

pool_count(env \\ :system)

@spec pool_count(env_source()) :: pos_integer() | nil

Get HTTP pool count from environment.

Set TINKEX_POOL_COUNT to override the number of connection pools.

pool_size(env \\ :system)

@spec pool_size(env_source()) :: pos_integer() | nil

Get HTTP pool size from environment.

Python SDK uses max_connections=1000 by default. Set TINKEX_POOL_SIZE to override.

proxy(env \\ :system)

@spec proxy(env_source()) :: String.t() | nil

Get proxy configuration from environment.

Set TINKEX_PROXY to a URL string like "http://proxy.example.com:8080" or "http://user:pass@proxy.example.com:8080".

proxy_headers(env \\ :system)

@spec proxy_headers(env_source()) :: [{String.t(), String.t()}]

Get proxy headers from environment.

Set TINKEX_PROXY_HEADERS to a JSON array of {name, value} tuples. Example: TINKEX_PROXY_HEADERS='[["proxy-authorization", "Basic abc123"]]'

redact(map)

@spec redact(map()) :: map()

Redact secrets in a snapshot or map using simple replacement.

snapshot(env \\ :system)

@spec snapshot(env_source()) :: map()

Snapshot all known env-driven values in one map.

tags(env \\ :system)

@spec tags(env_source()) :: [String.t()]

telemetry_enabled?(env \\ :system)

@spec telemetry_enabled?(env_source()) :: boolean()