MM-11262: database config store (#10281)
* vendor github.com/jmoiron/sqlx * MM-11262: introduce a database store * revert unnecessary fmt.Errorf * simplify unit test helper methods * remote TODO re: retry * relocate initializeConfigurationsTable for clarity * factor out a commonStore * acquire database config lock on close for safety * add missing header * fix lock comment
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
898a3a289c
Коммит
9bf5687311
@@ -51,7 +51,7 @@ func setupTestHelper(enterprise bool, tb testing.TB) *TestHelper {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
options := []Option{ConfigFile(tempConfig.Name(), false)}
|
||||
options := []Option{Config(tempConfig.Name(), false)}
|
||||
options = append(options, StoreOverride(mainHelper.Store))
|
||||
options = append(options, SetLogger(mlog.NewTestingLogger(tb)))
|
||||
|
||||
|
||||
@@ -38,11 +38,12 @@ func StoreOverride(override interface{}) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func ConfigFile(file string, watch bool) Option {
|
||||
// Config applies the given config dsn, whether a path to config.json or a database connection string.
|
||||
func Config(dsn string, watch bool) Option {
|
||||
return func(s *Server) error {
|
||||
configStore, err := config.NewFileStore(file, watch)
|
||||
configStore, err := config.NewStore(dsn, watch)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to apply ConfigFile option")
|
||||
return errors.Wrap(err, "failed to apply Config option")
|
||||
}
|
||||
|
||||
s.configStore = configStore
|
||||
@@ -50,6 +51,7 @@ func ConfigFile(file string, watch bool) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigStore applies the given config store, typically to replace the traditional sources with a memory store for testing.
|
||||
func ConfigStore(configStore config.Store) Option {
|
||||
return func(s *Server) error {
|
||||
s.configStore = configStore
|
||||
|
||||
Ссылка в новой задаче
Block a user