Foundation.Logic.ConfigLogic (foundation v0.1.0)

Pure business logic functions for configuration operations.

Contains configuration manipulation, merging, and transformation logic. No side effects - all functions are pure and easily testable.

Summary

Functions

Build a configuration from environment and options.

Create a configuration diff between two configs.

Get a configuration value by path.

Merge configuration with environment overrides.

Merge configuration with keyword list overrides.

Reset configuration to defaults.

Check if a configuration path can be updated at runtime.

Get the list of paths that can be updated at runtime.

Update a configuration value at the given path. Returns the updated configuration if successful.

Types

config_path()

@type config_path() :: [atom()]

config_value()

@type config_value() :: term()

Functions

build_config(opts \\ [])

@spec build_config(keyword()) ::
  {:ok, Foundation.Types.Config.t()} | {:error, Foundation.Types.Error.t()}

Build a configuration from environment and options.

diff_configs(old_config, new_config)

Create a configuration diff between two configs.

get_config_value(config, path)

@spec get_config_value(Foundation.Types.Config.t(), config_path()) ::
  {:ok, config_value()} | {:error, Foundation.Types.Error.t()}

Get a configuration value by path.

merge_env_config(config, env_config)

@spec merge_env_config(
  Foundation.Types.Config.t(),
  keyword()
) :: Foundation.Types.Config.t()

Merge configuration with environment overrides.

merge_opts_config(config, opts)

@spec merge_opts_config(
  Foundation.Types.Config.t(),
  keyword()
) :: Foundation.Types.Config.t()

Merge configuration with keyword list overrides.

reset_config()

@spec reset_config() :: Foundation.Types.Config.t()

Reset configuration to defaults.

updatable_path?(path)

@spec updatable_path?(config_path()) :: boolean()

Check if a configuration path can be updated at runtime.

updatable_paths()

@spec updatable_paths() :: [[atom(), ...], ...]

Get the list of paths that can be updated at runtime.

update_config(config, path, value)

Update a configuration value at the given path. Returns the updated configuration if successful.