Skip to content

Commit

Permalink
Use zap logger when initialising dynamic config (cadence-workflow#5081)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-sidlauskas authored Feb 16, 2023
1 parent caeeec1 commit 3ff8c89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,32 @@ func (s *server) startService() common.Daemon {

err = nil
if s.cfg.DynamicConfig.Client == "" {
//try to fallback to legacy dynamicClientConfig
params.Logger.Warn("falling back to legacy file based dynamicClientConfig")
params.DynamicConfig, err = dynamicconfig.NewFileBasedClient(&s.cfg.DynamicConfigClient, params.Logger, s.doneC)
} else {
switch s.cfg.DynamicConfig.Client {
case dynamicconfig.DynamicConfigConfigStoreClient:
log.Printf("Trying to initialize Config Store Dynamic Config Client\n")
case dynamicconfig.ConfigStoreClient:
params.Logger.Info("initialising ConfigStore dynamic config client")
params.DynamicConfig, err = configstore.NewConfigStoreClient(
&s.cfg.DynamicConfig.ConfigStore,
&s.cfg.Persistence,
params.Logger,
s.doneC,
)
case dynamicconfig.DynamicConfigFileBasedClient:
log.Printf("Trying to initialize File Based Dynamic Config Client\n")
case dynamicconfig.FileBasedClient:
params.Logger.Info("initialising File Based dynamic config client")
params.DynamicConfig, err = dynamicconfig.NewFileBasedClient(&s.cfg.DynamicConfig.FileBased, params.Logger, s.doneC)
default:
log.Printf("Trying to initialize Nop Config Client\n")
params.Logger.Info("initialising NOP dynamic config client")
params.DynamicConfig = dynamicconfig.NewNopClient()
}
}

if err != nil {
log.Printf("error creating dynamic config client, using no-op config client instead. error: %v", err)
params.Logger.Error("creating dynamic config client failed, using no-op config client instead", tag.Error(err))
params.DynamicConfig = dynamicconfig.NewNopClient()
}

clusterGroupMetadata := s.cfg.ClusterGroupMetadata
dc := dynamicconfig.NewCollection(
params.DynamicConfig,
Expand Down
8 changes: 4 additions & 4 deletions common/dynamicconfig/clientInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
)

const (
DynamicConfigConfigStoreClient = "configstore"
DynamicConfigFileBasedClient = "filebased"
DynamicConfigInMemoryClient = "memory"
DynamicConfigNopClient = "nop"
ConfigStoreClient = "configstore"
FileBasedClient = "filebased"
InMemoryClient = "memory"
NopClient = "nop"
)

// Client allows fetching values from a dynamic configuration system NOTE: This does not have async
Expand Down

0 comments on commit 3ff8c89

Please sign in to comment.