ConfigStore

ConfigStore for runtime configuration management.

Provides thread-safe access to configuration with support for dynamic updates and change subscriptions.

class varlord.store.ConfigDiff(added, modified, deleted)[source]

Bases: object

Represents changes between two configuration snapshots.

added: Dict[str, Any]
modified: Dict[str, tuple[Any, Any]]
deleted: Dict[str, Any]
__init__(added, modified, deleted)
class varlord.store.ConfigStore(resolver, model)[source]

Bases: object

Thread-safe configuration store with dynamic update support.

Provides: - Atomic configuration snapshots - Thread-safe get() and attribute access - Change subscriptions - Automatic validation on updates

__init__(resolver, model)[source]

Initialize ConfigStore.

Parameters:
  • resolver (Resolver) – Resolver for merging sources

  • model (Type[Any]) – Dataclass model for type conversion and validation

Note

Watch is automatically enabled if any source supports it.

get()[source]

Get current configuration (thread-safe).

Returns:

Current model instance

Return type:

Any

to_dict()[source]

Get current configuration as dictionary (thread-safe).

Returns:

Current configuration dictionary

Return type:

Dict[str, Any]

subscribe(callback)[source]

Subscribe to configuration changes.

Parameters:

callback (Callable[[Any, ConfigDiff], None]) – Function called with (new_config, diff) on changes

Note

Callbacks are called when: - Configuration changes are detected via watch (if any source supports it) - Manual reload() is called and configuration has changed

If no sources support watch, callbacks will only be called on manual reload().

reload()[source]

Manually reload configuration from sources.

__getattr__(name)[source]

Allow attribute access to configuration.

__repr__()[source]

Return string representation.