Documentation
¶
Overview ¶
Package migration lets FastConf rewrite the merged map from one schema version to another before it is decoded into the strongly typed snapshot. It addresses the "long-lived config + evolving struct" pain point: instead of forcing every operator to hand-edit every overlay file, a Migration shifts ageing keys (e.g. db.url -> db.dsn) on the fly during reload.
Migrations form an explicit chain keyed by _meta.schemaVersion. The chain runs after merge but before transform/decode; the final version is written back into _meta.schemaVersion so subsequent reloads fast-skip already-migrated input.
Index ¶
Constants ¶
const FieldKey = "schemaVersion"
FieldKey is the field inside MetaKey holding an int.
const MetaKey = "_meta"
MetaKey is the conventional path inside the merged map storing the current schema version: _meta.schemaVersion.
Variables ¶
This section is empty.
Functions ¶
func CurrentVersion ¶
CurrentVersion reads m._meta.schemaVersion. Missing or non-int values are treated as version 0 (assume the oldest schema).
func SetVersion ¶
SetVersion writes m._meta.schemaVersion = v, creating _meta if absent.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain is an ordered, validated set of Migrations that can be applied in sequence. Use New(...) to construct one.
func New ¶
New builds a Chain ensuring every migration's From == previous.To (gap- and dup-free). target is the highest schemaVersion the chain can reach; clients should set it to the latest version their typed struct understands.