LlmCore.Config.Store (llm_core v0.3.0)

Copy Markdown View Source

Lightweight ETS-backed storage for runtime configuration.

The store keeps the latest routing tables, provider definitions, CLI configs, and other hot-reloadable artifacts so they can be accessed without disk I/O.

Stored Namespaces

  • {:config, :routing} — Current RoutingTable
  • {:config, :providers} — Map of %Definition{} structs keyed by provider id
  • {:config, :cli_providers} — Map of %CLIProvider.Config{} structs keyed by atom name
  • {:config, :telemetry} — Telemetry settings map
  • {:config, :raw} — Raw merged TOML configuration

Access Patterns

Direct ETS reads (no GenServer call):

{:ok, table} = LlmCore.Config.Store.get_routing()
{:ok, providers} = LlmCore.Config.Store.fetch(:config, :providers)

Writes go through the GenServer for serialisation:

:ok = LlmCore.Config.Store.put_routing(%RoutingTable{...})
:ok = LlmCore.Config.Store.put(:config, :telemetry, %{...})

Summary

Functions

Returns a specification to start this module under a supervisor.

Fetches a value previously stored with put/3.

Fetches the current routing table.

Generic helper for storing custom config namespaces.

Stores the current routing table.

Starts the config store GenServer and creates the backing ETS table.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

fetch(namespace, key)

@spec fetch(atom(), atom()) :: {:ok, term()} | {:error, :not_found}

Fetches a value previously stored with put/3.

get_routing()

@spec get_routing() :: {:ok, LlmCore.Router.RoutingTable.t()} | {:error, :not_found}

Fetches the current routing table.

put(namespace, key, value)

@spec put(atom(), atom(), term()) :: :ok

Generic helper for storing custom config namespaces.

put_routing(table)

@spec put_routing(LlmCore.Router.RoutingTable.t()) :: :ok

Stores the current routing table.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the config store GenServer and creates the backing ETS table.