Documentation ¶
Overview ¶
Package dnmig1 provides configuration file settings downwards Migrator for settings major version 1 and its Adapter type for the version-independent repo.DownMigrator[migrationuc.Settings] interface.
The settings.DownMigrator generic interface is employed in order to ensure that this version-specific implementation uses consistent types as its method return types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Adapt ¶
func Adapt(m *Migrator) repo.DownMigrator[migrationuc.Settings]
Adapt creates an instance of Adapter struct wraping the `m` argument. Because Adapter expects to wrap a Type instance, it asserts that Migrator struct implements the Type interface, its implementation is correct (considering the expected return types), and provides the repo.DownMigrator[migrationuc.Settings] interface.
func NewDnMig ¶
func NewDnMig(c *cfg1.Config) repo.DownMigrator[migrationuc.Settings]
NewDnMig creates a Migrator struct wrapping the given Config instance and then uses the Adapt function in order to adapt it to the version independent repo.DownMigrator[migrationuc.Settings] interface.
The Migrator struct is exported and users which need a concrete type can create it directly and wrap the `c` instance. This helper New function is provided in order to combine these two steps (of creation and adaptation) together.
Types ¶
type Adapter ¶
type Adapter struct {
T Type
}
Adapter wraps and adapts an instance of Type in order to provide the repo.DownMigrator[migrationuc.Settings] interface.
func (Adapter) MigrateDown ¶
func (a Adapter) MigrateDown(ctx context.Context) ( repo.DownMigrator[migrationuc.Settings], error, )
MigrateDown calls the wrapped Type MigrateDown method, obtains the next downwards migrator object, and adapts it to the version independent repo.DownMigrator[migrationuc.Settings] interface using the Adapt function. Since major version 1 has no downer version, this method always returns an error.
func (Adapter) Settler ¶
func (a Adapter) Settler() migrationuc.Settings
Settler calls the wrapped Type Settler method, obtains a C instance, and wraps it by settings.Adapter[C, S] in order to expose an instance of migrationuc.Settings interface.
type Migrator ¶
Migrator is a downwards Config migrator for *cfg1.Config instances. It wraps a Config struct (with major version 1) and implements the repo.Settler and pkg/adapter/config/settings.DownMigrator generic interfaces.
func (*Migrator) MigrateDown ¶
MigrateDown should migrate the wrapped cfg1.Config instance to its older version and wrap it by a corresponding downwards migrator. However, since major version 1 has no older major version, this method always returns an error.
func (Migrator) Settler ¶
Settler returns the wrapped Config object. After migrating from a source Config version downwards and reaching to an ultimate version, this method reveals the final migrated Config object. This object may have some uninitialized settings too. The MergeConfig method may be used in order to fill them from another Config instance containing the default settings for major version 1.
type S ¶ added in v1.2.0
type S = cfg1.Serializable
S is the Serializable struct type containing mutable settings