Expand description
ConfigSource — where the settings layers come from.
LoadedSettings::load merges three tiers, each with a gitignored overlay beside
it, and it read all six with std::fs::read_to_string. That made the file
system part of the definition of “configuration”: a deployment that keeps
its settings in a config service, a Kubernetes ConfigMap, or a database had
no way in that did not involve writing six files to disk first so the
engine could read them back.
What moves is only where the layers come from. The merge — six layers
low-to-high, generic recursive JSON merge, paths stripped from every
layer, the permissions rule lists from an overlay held apart — stays exactly where
it was, in settings::LoadedSettings::load_from. A source hands over
JSON values in priority order and has no say in what happens to them,
which is what keeps “settings come from somewhere else” from turning into
“settings mean something else”.
§A source reports its own failures and yields nothing
LoadedSettings::load never fails: a layer that is absent is skipped, and one
that will not parse is skipped with a warning rather than taking startup
down with it. That property belongs to the loader and cannot be delegated,
so ConfigSource::layers returns layers rather than a Result — a
source that cannot reach its backing store logs why and returns what it
has. Losing a layer is bad; refusing to start because a remote service is
slow is worse.
§Synchronous, and a remote source is still a fit
Configuration is read once, before anything is built, and every caller of
LoadedSettings::load today is synchronous. A source that has to go over a
network fetches in ConfigSource::layers — it is called once per process
and is allowed to be slow — or fetches ahead of time and hands the result
over as InMemoryLayers. Chain is for the common shape of the second
case: the files on disk, with what the control plane says layered on top.
Structs§
- Chain
- Several sources end to end, each outranking the one before it.
- Config
Layer - One layer of configuration, already parsed.
- InMemory
Layers - Layers the host already has in hand.
Enums§
- Tier
- Which tier a layer belongs to, lowest priority first.
Traits§
- Config
Source - Where the settings layers come from.