Raxol.Core.Config.ConfigServer (Raxol Core v2.4.0)

Copy Markdown View Source

Backward-compatible configuration server.

This module maintains the original API but delegates to the pure functional Raxol.Core.Config module and ETS-backed Raxol.Core.Config.Store.

Migration Note

This module is retained for backward compatibility. New code should use:

Architecture Change

Previous: All operations serialized through GenServer mailbox Current: Reads go directly to ETS, writes coordinate through GenServer

This change improves:

  • Read performance (no mailbox serialization)
  • Concurrent access (ETS read_concurrency)
  • Code clarity (pure functions separated from process management)

Summary

Functions

Gets configuration value from specified namespace and key.

Gets entire namespace configuration.

Loads configuration from file system.

Resets namespace to default configuration.

Saves configuration to file system.

Sets configuration value in specified namespace and key.

Sets entire namespace configuration.

Starts the configuration store.

Validates configuration for specified namespace.

Types

config_key()

@type config_key() :: Raxol.Core.Config.key()

config_namespace()

@type config_namespace() :: Raxol.Core.Config.namespace()

config_value()

@type config_value() :: Raxol.Core.Config.value()

Functions

child_spec(opts)

get(server \\ __MODULE__, namespace, key, default \\ nil)

@spec get(GenServer.server(), config_namespace(), config_key(), any()) :: any()

Gets configuration value from specified namespace and key.

This is now a direct ETS read - fast and concurrent.

get_namespace(server \\ __MODULE__, namespace)

@spec get_namespace(GenServer.server(), config_namespace()) :: map()

Gets entire namespace configuration.

Direct ETS read - fast and concurrent.

load_from_file(server \\ __MODULE__)

@spec load_from_file(GenServer.server()) :: :ok | {:error, any()}

Loads configuration from file system.

reset_namespace(server \\ __MODULE__, namespace)

@spec reset_namespace(GenServer.server(), config_namespace()) :: :ok

Resets namespace to default configuration.

save_to_file(server \\ __MODULE__)

@spec save_to_file(GenServer.server()) :: :ok | {:error, any()}

Saves configuration to file system.

set(server \\ __MODULE__, namespace, key, value)

@spec set(
  GenServer.server(),
  config_namespace(),
  config_key(),
  config_value()
) :: :ok | {:error, any()}

Sets configuration value in specified namespace and key.

set_namespace(server \\ __MODULE__, namespace, config)

@spec set_namespace(GenServer.server(), config_namespace(), map()) :: :ok

Sets entire namespace configuration.

start_link(opts \\ [])

Starts the configuration store.

Kept for backward compatibility - delegates to Config.Store.

validate(server \\ __MODULE__, namespace)

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

Validates configuration for specified namespace.