[MM-60262] Respect config store option when creating platform service (#28038)

* Respect config store option when creating platform service

* Remove ConfigStore from ServiceConfig
Этот коммит содержится в:
Ben Schumacher
2024-08-28 07:02:09 +02:00
коммит произвёл GitHub
родитель 244b7e565b
Коммит 5ff680d20d
5 изменённых файлов: 40 добавлений и 35 удалений

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

@@ -117,7 +117,6 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
// ConfigStore is and should be handled on a upper level.
ps := &PlatformService{
Store: sc.Store,
configStore: sc.ConfigStore,
clusterIFace: sc.Cluster,
hashSeed: maphash.MakeSeed(),
goroutineExitSignal: make(chan struct{}, 1),
@@ -137,6 +136,13 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
// Assume the first user account has not been created yet. A call to the DB will later check if this is really the case.
ps.isFirstUserAccount.Store(true)
// Apply options, some of the options overrides the default config actually.
for _, option := range options {
if err2 := option(ps); err2 != nil {
return nil, fmt.Errorf("failed to apply option: %w", err2)
}
}
// the config store is not set, we need to create a new one
if ps.configStore == nil {
innerStore, err := config.NewFileStore("config.json", true)
@@ -177,13 +183,6 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
return nil, fmt.Errorf("unable to connect to cache provider: %w", err)
}
// Apply options, some of the options overrides the default config actually.
for _, option := range options {
if err2 := option(ps); err2 != nil {
return nil, fmt.Errorf("failed to apply option: %w", err2)
}
}
// Step 2: Start logging.
if err2 := ps.initLogging(); err2 != nil {
return nil, fmt.Errorf("failed to initialize logging: %w", err2)