Quant.Explorer.Config (quant v0.1.0-alpha.1)

Centralized configuration management for Quant.Explorer.

This module provides a consistent interface for accessing configuration values from application environment, with sensible defaults and runtime value resolution (e.g., from system environment variables).

Summary

Functions

Gets an API key for a specific provider.

Gets all API keys as a map, resolving system environment variables.

Gets the caching configuration.

Gets the cache TTL (time-to-live) in milliseconds.

Gets a configuration value for the given key.

Gets the HTTP timeout in milliseconds.

Gets the log level for the application.

Gets the configuration for a specific provider.

Gets the rate limit for a specific provider (requests per minute). This is kept for backwards compatibility but new code should use the provider-specific configurations.

Gets the rate limiting configuration including backend and provider-specific settings.

Checks if telemetry is enabled.

Gets the user agent string for HTTP requests.

Validates that required configuration is present.

Functions

api_key(provider)

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

Gets an API key for a specific provider.

Handles runtime resolution of system environment variables.

api_keys()

@spec api_keys() :: map()

Gets all API keys as a map, resolving system environment variables.

cache_config()

@spec cache_config() :: keyword()

Gets the caching configuration.

cache_ttl()

@spec cache_ttl() :: pos_integer()

Gets the cache TTL (time-to-live) in milliseconds.

get(key, default \\ nil)

@spec get(atom() | [atom()], term()) :: term()

Gets a configuration value for the given key.

Supports nested keys using dot notation as atoms:

  • get(:api_keys)
  • get([:rate_limits, :yahoo_finance])
  • get(:http_timeout)

Returns the default value if the configuration is not found.

http_timeout()

@spec http_timeout() :: pos_integer()

Gets the HTTP timeout in milliseconds.

log_level()

@spec log_level() :: atom()

Gets the log level for the application.

provider_config(provider)

@spec provider_config(atom()) :: map()

Gets the configuration for a specific provider.

Returns a map with provider-specific configuration including rate limits, API keys, base URLs, etc.

rate_limit(provider)

@spec rate_limit(atom()) :: pos_integer()

Gets the rate limit for a specific provider (requests per minute). This is kept for backwards compatibility but new code should use the provider-specific configurations.

rate_limiting_config()

@spec rate_limiting_config() :: map()

Gets the rate limiting configuration including backend and provider-specific settings.

telemetry_enabled?()

@spec telemetry_enabled?() :: boolean()

Checks if telemetry is enabled.

user_agent()

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

Gets the user agent string for HTTP requests.

validate_config()

@spec validate_config() :: :ok | {:error, [atom()]}

Validates that required configuration is present.

Returns :ok if all required config is present, or {:error, missing_keys} if anything is missing.