AgentSessionManager.Config (AgentSessionManager v0.1.1)

Copy Markdown View Source

Centralized configuration with process-local overrides.

Configuration values are resolved in priority order:

  1. Process-local override — set via put/2, scoped to the calling process. Automatically cleaned up when the process exits.
  2. Application environment — set via config :agent_session_manager, key: value or Application.put_env/3.
  3. Built-in default — hardcoded fallback per key.

This layering follows the same pattern as Elixir's Logger module for per-process log levels. It enables fully concurrent (async: true) testing because each test process can override configuration without affecting any other process.

Supported Keys

KeyTypeDefault
:telemetry_enabledbooleantrue
:audit_logging_enabledbooleantrue

Examples

# Read (checks process-local first, then app env, then default)
AgentSessionManager.Config.get(:telemetry_enabled)
#=> true

# Set process-local override
AgentSessionManager.Config.put(:telemetry_enabled, false)
AgentSessionManager.Config.get(:telemetry_enabled)
#=> false

# Clear process-local override (falls back to app env / default)
AgentSessionManager.Config.delete(:telemetry_enabled)

Summary

Types

Configuration keys supported by this module.

Functions

Returns the built-in default for key.

Removes the process-local override for key.

Returns the resolved value for key.

Sets a process-local override for key.

Types

key()

@type key() :: :telemetry_enabled | :audit_logging_enabled

Configuration keys supported by this module.

Functions

default(atom)

@spec default(key()) :: term()

Returns the built-in default for key.

delete(key)

@spec delete(key()) :: :ok

Removes the process-local override for key.

After deletion, get/1 falls back to Application environment or the built-in default.

get(key)

@spec get(key()) :: term()

Returns the resolved value for key.

Checks the process dictionary first, then Application environment, then falls back to the built-in default.

put(key, value)

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

Sets a process-local override for key.

This override is visible only to the calling process and is automatically cleaned up when the process exits. It takes priority over Application environment and built-in defaults.