Raxol.Config (Raxol v2.0.1)

View Source

Unified TOML-based configuration management for Raxol.

This module provides a centralized configuration system that:

  • Loads configuration from TOML files
  • Supports environment-specific configs
  • Provides runtime configuration updates
  • Validates configuration values
  • Supports default values and overrides

Summary

Functions

Gets the entire configuration map.

Returns a specification to start this module under a supervisor.

Exports current configuration to a TOML file.

Gets a configuration value by path.

Loads configuration from a TOML file.

Reloads all configuration files.

Sets a configuration value at runtime.

Starts the configuration server.

Validates the current configuration.

Types

config_map()

@type config_map() :: %{required(String.t()) => config_value()}

config_path()

@type config_path() :: [atom() | String.t()]

config_value()

@type config_value() :: any()

Functions

all()

@spec all() :: config_map()

Gets the entire configuration map.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

export(file_path)

@spec export(String.t()) :: :ok | {:error, any()}

Exports current configuration to a TOML file.

get(path, opts \\ [])

@spec get(
  config_path(),
  keyword()
) :: config_value()

Gets a configuration value by path.

Examples

# Get terminal width
Config.get([:terminal, :width])

# Get with default value
Config.get([:terminal, :custom], default: 80)

handle_manager_call(request, from, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_call/3.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

load_file(file_path)

@spec load_file(String.t()) :: {:ok, config_map()} | {:error, any()}

Loads configuration from a TOML file.

reload()

@spec reload() :: :ok | {:error, any()}

Reloads all configuration files.

set(path, value)

@spec set(config_path(), config_value()) :: :ok

Sets a configuration value at runtime.

Examples

Config.set([:terminal, :width], 120)

start_link(init_opts \\ [])

validate()

@spec validate() :: {:ok, :valid} | {:error, [String.t()]}

Validates the current configuration.