Skip to content

Commit

Permalink
dynamicconfig: Make Keys public for use in extension clients (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Mar 26, 2021
1 parent 285514c commit 1ff79f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/dynamicconfig/config_test.go
Expand Up @@ -273,7 +273,7 @@ func (s *configSuite) TestUpdateConfig() {

func TestDynamicConfigKeyIsMapped(t *testing.T) {
for i := unknownKey; i < lastKeyForTest; i++ {
key, ok := keys[i]
key, ok := Keys[i]
require.True(t, ok, fmt.Sprintf("key %d is not mapped", i))
require.NotEmpty(t, key)
}
Expand Down
8 changes: 4 additions & 4 deletions common/dynamicconfig/constants.go
Expand Up @@ -32,15 +32,15 @@ import (
type Key int

func (k Key) String() string {
keyName, ok := keys[k]
keyName, ok := Keys[k]
if !ok {
return keys[unknownKey]
return Keys[unknownKey]
}
return keyName
}

// Mapping from Key to keyName, where keyName are used dynamic config source.
var keys = map[Key]string{
// Keys represents a mapping from Key to keyName, where keyName are used dynamic config source.
var Keys = map[Key]string{
unknownKey: "unknownKey",

// tests keys
Expand Down
4 changes: 2 additions & 2 deletions common/dynamicconfig/file_based_client.go
Expand Up @@ -190,7 +190,7 @@ func (fc *fileBasedClient) GetDurationValue(
}

func (fc *fileBasedClient) UpdateValue(name Key, value interface{}) error {
keyName := keys[name]
keyName := Keys[name]
currentValues := make(map[string][]*constrainedValue)

confContent, err := ioutil.ReadFile(fc.config.Filepath)
Expand Down Expand Up @@ -264,7 +264,7 @@ func (fc *fileBasedClient) storeValues(newValues map[string][]*constrainedValue)
}

func (fc *fileBasedClient) getValueWithFilters(key Key, filters map[Filter]interface{}, defaultValue interface{}) (interface{}, error) {
keyName := keys[key]
keyName := Keys[key]
values := fc.values.Load().(map[string][]*constrainedValue)
found := false
for _, constrainedValue := range values[keyName] {
Expand Down

0 comments on commit 1ff79f2

Please sign in to comment.