LemonCore.ConfigReloader (lemon_core v0.1.0)

View Source

Central orchestrator for runtime config reload.

Detects config changes from files, environment, and secrets, reloads the canonical config, computes a redacted diff, and broadcasts update events on LemonCore.Bus.

Reload Pipeline

  1. Acquire reload lock (serialize concurrent reloads)
  2. Compute current source digests
  3. Determine changed sources (skip if unchanged and not forced)
  4. If env source changed, reload .env
  5. Reload canonical config via LemonCore.Config.reload/2
  6. Compute redacted diff vs previous snapshot
  7. Persist new snapshot + digests
  8. Broadcast %LemonCore.Event{type: :config_reloaded} on topic "system"
  9. On failure, keep last good snapshot and emit :config_reload_failed

Telemetry

  • [:lemon, :config, :reload, :start]
  • [:lemon, :config, :reload, :stop]
  • [:lemon, :config, :reload, :exception]

Summary

Functions

Returns a specification to start this module under a supervisor.

Trigger a config reload.

Trigger a reload asynchronously. Fire-and-forget.

Starts the ConfigReloader GenServer.

Return current reloader status.

Return the list of file paths being watched.

Types

reload_result()

@type reload_result() :: %{
  reload_id: String.t(),
  changed_sources: [source()],
  changed_paths: [String.t()],
  applied_at_ms: non_neg_integer(),
  actions: [map()]
}

source()

@type source() :: :files | :env | :secrets

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

reload(opts \\ [])

@spec reload(keyword()) :: {:ok, reload_result()} | {:error, term()}

Trigger a config reload.

Options

  • :sources - list of sources to check (default: [:files, :env, :secrets])
  • :force - bypass digest comparison and force reload (default: false)
  • :reason - why the reload was triggered (:watcher, :poll, :manual, :secrets_event)
  • :cwd - override the working directory for config lookup
  • :validate - run config validation (default: true)

reload_async(opts \\ [])

@spec reload_async(keyword()) :: :ok

Trigger a reload asynchronously. Fire-and-forget.

start_link(opts \\ [])

Starts the ConfigReloader GenServer.

status()

@spec status() :: map()

Return current reloader status.

watch_paths()

@spec watch_paths() :: [String.t()]

Return the list of file paths being watched.