[MM-32390] Config logic refactor (#17578)

* Replace config generator

* Cleanup

* Some renaming and docs additions to add clarity

* Cleanup logging related methods

* Cleanup emitter

* Fix TestDefaultsGenerator

* Move feature flags synchronization logic out of config package

* Remove unnecessary util functions

* Simplify load/set logic

* Refine semantics and add some test to cover them

* Remove unnecessary deep copies

* Improve logic further

* Fix license header

* Review file store tests

* Fix test

* Fix test

* Avoid additional write during initialization

* More consistent naming

* Update app/feature_flags.go

Co-authored-by: Christopher Speller <crspeller@gmail.com>

* Update config/store.go

Co-authored-by: Christopher Speller <crspeller@gmail.com>

* Update config/store.go

Co-authored-by: Christopher Speller <crspeller@gmail.com>

* Update config/store.go

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>

* Move FF synchronizer to its own package

* Remove unidiomatic use of sync.Once

* Add some comments

* Rename function

* More comment

Co-authored-by: Christopher Speller <crspeller@gmail.com>
Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
Claudio Costa
2021-05-19 13:30:26 +02:00
коммит произвёл GitHub
родитель b810a40062
Коммит 3681cd3688
37 изменённых файлов: 819 добавлений и 668 удалений

Просмотреть файл

@@ -146,7 +146,7 @@ func getConfigStore(command *cobra.Command) (*config.Store, error) {
return nil, errors.Wrap(err, "failed to initialize i18n")
}
configStore, err := config.NewStore(getConfigDSN(command, config.GetEnvironment()), false, false, nil)
configStore, err := config.NewStoreFromDSN(getConfigDSN(command, config.GetEnvironment()), false, false, nil)
if err != nil {
return nil, errors.Wrap(err, "failed to initialize config store")
}

Просмотреть файл

@@ -543,9 +543,9 @@ func TestConfigMigrate(t *testing.T) {
sqlDSN := getDsn(*sqlSettings.DriverName, *sqlSettings.DataSource)
fileDSN := "config.json"
ds, err := config.NewStore(sqlDSN, false, false, nil)
ds, err := config.NewStoreFromDSN(sqlDSN, false, false, nil)
require.NoError(t, err)
fs, err := config.NewStore(fileDSN, false, false, nil)
fs, err := config.NewStoreFromDSN(fileDSN, false, false, nil)
require.NoError(t, err)
defer ds.Close()

Просмотреть файл

@@ -57,7 +57,7 @@ func initDbCmdF(command *cobra.Command, _ []string) error {
return errors.Wrap(err, "error loading custom configuration defaults")
}
configStore, err := config.NewStore(getConfigDSN(command, config.GetEnvironment()), false, false, customDefaults)
configStore, err := config.NewStoreFromDSN(getConfigDSN(command, config.GetEnvironment()), false, false, customDefaults)
if err != nil {
return errors.Wrap(err, "failed to load configuration")
}

Просмотреть файл

@@ -52,7 +52,7 @@ func serverCmdF(command *cobra.Command, args []string) error {
mlog.Warn("Error loading custom configuration defaults: " + err.Error())
}
configStore, err := config.NewStore(getConfigDSN(command, config.GetEnvironment()), !disableConfigWatch, false, customDefaults)
configStore, err := config.NewStoreFromDSN(getConfigDSN(command, config.GetEnvironment()), !disableConfigWatch, false, customDefaults)
if err != nil {
return errors.Wrap(err, "failed to load configuration")
}