Skip to content

Commit

Permalink
Set poll interval for filebased dynamic config if not set (cadence-wo…
Browse files Browse the repository at this point in the history
…rkflow#5160)

* Set poll interval for filebased dynamic config if not set

* update unit test
  • Loading branch information
mantas-sidlauskas authored Mar 16, 2023
1 parent 42a14b1 commit 1304570
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion common/dynamicconfig/file_based_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ func validateConfig(config *FileBasedClientConfig) error {
if _, err := os.Stat(config.Filepath); err != nil {
return fmt.Errorf("error checking dynamic config file at path %s, error: %v", config.Filepath, err)
}

// check if poll interval needs to be adjusted
if config.PollInterval < minPollInterval {
return fmt.Errorf("poll interval should be at least %v", minPollInterval)
config.PollInterval = minPollInterval
}
return nil
}
9 changes: 6 additions & 3 deletions common/dynamicconfig/file_based_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,14 @@ func (s *fileBasedClientSuite) TestValidateConfig_FileNotExist() {
}

func (s *fileBasedClientSuite) TestValidateConfig_ShortPollInterval() {
_, err := NewFileBasedClient(&FileBasedClientConfig{
cfg := &FileBasedClientConfig{
Filepath: "config/testConfig.yaml",
PollInterval: time.Second,
}, nil, nil)
s.Error(err)
}
_, err := NewFileBasedClient(cfg, log.NewNoop(), nil)
s.NoError(err)
s.Equal(minPollInterval, cfg.PollInterval, "fallback to default poll interval")

}

func (s *fileBasedClientSuite) TestMatch() {
Expand Down

0 comments on commit 1304570

Please sign in to comment.