Skip to main content

Module tagged_seq

Module tagged_seq 

Source
Expand description

Environment overrides for configuration keys holding a sequence of tagged tables.

Such a sequence is what a Vec of externally tagged enums serializes to, for example the region_engine option:

[{"mito": {...}}, {"file": {...}}]

Handing the plain [Environment] source to config cannot work for these keys: config writes every flat dotted key by walking down its path, and the walk resets any intermediate value that is not a table. Walking region_engine.mito.index.aux_path therefore destroys the default sequence before anything is set.

This source instead addresses the entries by their tag name and merges the overrides onto the matching default entries:

GREPTIMEDB_STANDALONE__REGION_ENGINE__MITO__INDEX__AUX_PATH=...

Entries that only the environment mentions are appended, and every field that is not mentioned keeps its default value. A configuration file that configures the whole sequence replaces the merged one, which makes these variables ineffective; the file has to spell out every entry it wants.

Structsยง

TaggedSeqEnvSource ๐Ÿ”’
A [Source] that merges environment overrides into sequences of tagged tables.
Target ๐Ÿ”’
One sequence of tagged tables that the environment may override.

Functionsยง

apply_override ๐Ÿ”’
Merges the override of the entry tag into entry, whose only key is tag.
deep_merge ๐Ÿ”’
Merges incoming into base, recursively for tables. Returns the dotted path of the field that cannot be merged into, when base holds a non-table value where incoming needs a table.
default_entries ๐Ÿ”’
Returns the default entries of target, each one a single-key table {tag: table}.
entry_path ๐Ÿ”’
Builds the dotted path of path below the entry tag of target.
group_entries ๐Ÿ”’
Groups the overrides by tag, nesting every field path into a table.
invalid_default ๐Ÿ”’
is_index_like ๐Ÿ”’
Whether tag looks like a position in the sequence rather than an engine name.
json_to_value ๐Ÿ”’
Converts a default value parsed from the JSON serialization of the options.
merge ๐Ÿ”’
Rebuilds the sequence of target with the environment overrides entries applied.
merge_at ๐Ÿ”’
nest ๐Ÿ”’
Builds a table whose key path is the dotted path, e.g. a.b and v give {a: {b: v}}.
not_a_table ๐Ÿ”’
Error for a field whose default value is not a table, so nothing can be set below it.
overrides_conflict ๐Ÿ”’
Error for a key that sets a field below a path another key sets as a whole.
single_tag ๐Ÿ”’
Returns the tag of entry, which must map one tag to a table.
take_entries ๐Ÿ”’
Removes and returns the entries that address key itself or one of its children.