Solaris.Config (Solaris v1.0.0)

Copy Markdown View Source

Runtime configuration for the Solaris client.

All values can be set via config :solaris, key: value and are read at runtime so they work with Config.Provider and runtime.exs.

Required

  • :client_id — OAuth2 client ID
  • :client_secret — OAuth2 client secret

Optional

KeyDefaultDescription
:environment:sandbox:sandbox or :production
:timeout30_000HTTP receive timeout in milliseconds
:max_retries3Retry count for 429/5xx responses
:pool_size10Finch connection pool size
:api_versionnilDefault Solaris-Version header
:telemetry_prefix[:solaris]Telemetry event prefix
:rate_limit_scale_ms1_000Rate limiter window in ms
:rate_limit_limit100Max requests per window
:webhook_secretnilHMAC secret for webhook signature verification
:base_url_overridenilOverride base URL (used in tests)

Example

# config/runtime.exs
config :solaris,
  client_id: System.fetch_env!("SOLARIS_CLIENT_ID"),
  client_secret: System.fetch_env!("SOLARIS_CLIENT_SECRET"),
  environment: :production,
  webhook_secret: System.get_env("SOLARIS_WEBHOOK_SECRET")

Summary

Functions

Returns the base API URL for the current environment.

Returns the configured client ID.

Returns the configured client secret.

Returns the configured environment atom.

Returns the current runtime config as a %Solaris.Config{} struct.

Returns the maximum retry count.

Returns the HTTP receive timeout in milliseconds.

Validates required config keys are present. Raises ArgumentError on failure.

Returns the webhook HMAC secret.

Types

t()

@type t() :: %Solaris.Config{
  api_version: String.t() | nil,
  base_url_override: String.t() | nil,
  client_id: String.t() | nil,
  client_secret: String.t() | nil,
  environment: :sandbox | :production,
  max_retries: non_neg_integer(),
  pool_size: pos_integer(),
  rate_limit_limit: pos_integer(),
  rate_limit_scale_ms: pos_integer(),
  telemetry_prefix: [atom()],
  timeout: pos_integer(),
  webhook_secret: String.t() | nil
}

Functions

base_url()

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

Returns the base API URL for the current environment.

client_id()

@spec client_id() :: String.t() | nil

Returns the configured client ID.

client_secret()

@spec client_secret() :: String.t() | nil

Returns the configured client secret.

environment()

@spec environment() :: :sandbox | :production

Returns the configured environment atom.

get()

@spec get() :: t()

Returns the current runtime config as a %Solaris.Config{} struct.

max_retries()

@spec max_retries() :: non_neg_integer()

Returns the maximum retry count.

timeout()

@spec timeout() :: pos_integer()

Returns the HTTP receive timeout in milliseconds.

validate!()

@spec validate!() :: :ok

Validates required config keys are present. Raises ArgumentError on failure.

Call once at application startup to surface config errors early.

webhook_secret()

@spec webhook_secret() :: String.t() | nil

Returns the webhook HMAC secret.