Expand description
Global layered configuration store.
This submodule defines the process-wide configuration layers
(File, Env, Runtime, and TestOverride), resolution order,
and guard types (ConfigLock, ConfigValueGuard) used for
testing. Use this when you need to read or temporarily override
values in the global configuration state.
Global layered configuration for Hyperactor.
This module provides the process-wide configuration store and APIs
to access it. Configuration values are resolved via a layered
model: TestOverride → Runtime → Env → File → Default.
- Reads (
get,get_cloned) consult layers in that order, falling back to defaults if no explicit value is set. attrs()returns a complete snapshot of all CONFIG-marked keys at call time: it materializes defaults for keys not set in any layer. Keys without @meta(CONFIG = …) are excluded.- In tests,
lock()andoverride_keyallow temporary overrides that are removed automatically when the guard drops. - In normal operation, a parent process can capture its effective
config via
attrs()and pass that snapshot to a child during bootstrap. The child installs it as aRuntimelayer so the parent’s values take precedence over Env/File/Defaults.
This design provides flexibility (easy test overrides, runtime updates, YAML/Env baselines) while ensuring type safety and predictable resolution order.
§Testing
Tests can override global configuration using [lock]. This
ensures such tests are serialized (and cannot clobber each other’s
overrides).
#[test]
fn test_my_feature() {
let config = hyperactor::config::global::lock();
let _guard = config.override_key(SOME_CONFIG_KEY, test_value);
// ... test logic here ...
}Structs§
- Config
Lock - A guard that holds the global configuration lock and provides override functionality.
- Config
Value Guard - A guard that restores a single configuration value when dropped
Enums§
- Source
- Configuration source layers in priority order.
Functions§
- attrs
- Return a complete, merged snapshot of the effective configuration
(only keys marked with
@meta(CONFIG = ...)). - create_
or_ merge - Insert or update a configuration layer for the given
Source. - get
- Get a key from the global configuration (Copy types).
- get_
cloned - Get a key by cloning the value.
- init_
from_ env - Initialize the global configuration from environment variables.
- init_
from_ yaml - Initialize the global configuration from a YAML file.
- lock
- Acquire the global configuration lock.
- override_
or_ global - Return the override value for
keyif it is explicitly present inoverrides, otherwise fall back to the global value for that key. - reset_
to_ defaults - Reset the global configuration to only Defaults (for testing).
- set
- Insert or replace a configuration layer for the given source.
- try_
get_ cloned - Try to get a key by cloning the value.