diff --git a/common/service/dynamicconfig/config.go b/common/service/dynamicconfig/config.go index a35ac5b919f..5a2483b1456 100644 --- a/common/service/dynamicconfig/config.go +++ b/common/service/dynamicconfig/config.go @@ -29,7 +29,7 @@ import ( // options right now. In the interest of keeping it minimal, we can add when requirement arises. type Client interface { GetValue(name Key) (interface{}, error) - GetValueWithConstraints(name Key, constraints map[ConstraintKey]interface{}) (interface{}, error) + GetValueWithFilters(name Key, filters map[Filter]interface{}) (interface{}, error) } type nopClient struct{} @@ -38,8 +38,8 @@ func (mc *nopClient) GetValue(name Key) (interface{}, error) { return nil, errors.New("unable to find key") } -func (mc *nopClient) GetValueWithConstraints( - name Key, constraints map[ConstraintKey]interface{}, +func (mc *nopClient) GetValueWithFilters( + name Key, filters map[Filter]interface{}, ) (interface{}, error) { return nil, errors.New("unable to find key") } @@ -59,12 +59,12 @@ type Collection struct { client Client } -// GetIntPropertyWithConstraints gets property based on constraints and asserts that it's an integer -func (c *Collection) GetIntPropertyWithConstraints( - key Key, defaultVal int, -) func(map[ConstraintKey]interface{}) int { - return func(constraints map[ConstraintKey]interface{}) int { - val, err := c.client.GetValue(key) +// GetIntPropertyWithTaskList gets property with taskList filter and asserts that it's an integer +func (c *Collection) GetIntPropertyWithTaskList(key Key, defaultVal int) func(string) int { + return func(taskList string) int { + filters := make(map[Filter]interface{}) + filters[TaskListName] = taskList + val, err := c.client.GetValueWithFilters(key, filters) if err != nil { return defaultVal } diff --git a/common/service/dynamicconfig/config_test.go b/common/service/dynamicconfig/config_test.go index 93a9910f9a9..da61048b0f3 100644 --- a/common/service/dynamicconfig/config_test.go +++ b/common/service/dynamicconfig/config_test.go @@ -47,8 +47,8 @@ func (mc *inMemoryClient) GetValue(key Key) (interface{}, error) { return nil, errors.New("unable to find key") } -func (mc *inMemoryClient) GetValueWithConstraints( - name Key, constraints map[ConstraintKey]interface{}, +func (mc *inMemoryClient) GetValueWithFilters( + name Key, filters map[Filter]interface{}, ) (interface{}, error) { return mc.GetValue(name) } diff --git a/common/service/dynamicconfig/constants.go b/common/service/dynamicconfig/constants.go index 0ecf9e63dd4..d0f87042565 100644 --- a/common/service/dynamicconfig/constants.go +++ b/common/service/dynamicconfig/constants.go @@ -51,23 +51,23 @@ const ( HistoryLongPollExpirationInterval ) -// ConstraintKey represents a key for a constraint on the dynamic config key -type ConstraintKey int +// Filter represents a filter on the dynamic config key +type Filter int -func (k ConstraintKey) String() string { +func (k Filter) String() string { keys := []string{ - "unknownConstraintKey", + "unknownFilter", "domainName", "taskListName", } - if k <= unknownConstraintKey || k > TaskListName { - return keys[unknownConstraintKey] + if k <= unknownFilter || k > TaskListName { + return keys[unknownFilter] } return keys[k] } const ( - unknownConstraintKey ConstraintKey = iota + unknownFilter Filter = iota // DomainName is the domain name DomainName // TaskListName is the tasklist name diff --git a/service/matching/service.go b/service/matching/service.go index 8de558d4834..be65eae3d3d 100644 --- a/service/matching/service.go +++ b/service/matching/service.go @@ -40,7 +40,7 @@ type Config struct { GetTasksBatchSize int UpdateAckInterval time.Duration IdleTasklistCheckInterval time.Duration - MinTaskThrottlingBurstSize func(map[dynamicconfig.ConstraintKey]interface{}) int + MinTaskThrottlingBurstSize func(string) int // taskWriter configuration OutstandingTaskAppendsThreshold int @@ -60,7 +60,7 @@ func NewConfig(dc *dynamicconfig.Collection) *Config { IdleTasklistCheckInterval: 5 * time.Minute, OutstandingTaskAppendsThreshold: 250, MaxTaskBatchSize: 100, - MinTaskThrottlingBurstSize: dc.GetIntPropertyWithConstraints( + MinTaskThrottlingBurstSize: dc.GetIntPropertyWithTaskList( dynamicconfig.MinTaskThrottlingBurstSize, 1, ), } diff --git a/service/matching/taskListManager.go b/service/matching/taskListManager.go index fdb76a9546e..289eb04de68 100644 --- a/service/matching/taskListManager.go +++ b/service/matching/taskListManager.go @@ -29,8 +29,6 @@ import ( "sync/atomic" "time" - "github.com/uber/cadence/common/service/dynamicconfig" - h "github.com/uber/cadence/.gen/go/history" m "github.com/uber/cadence/.gen/go/matching" s "github.com/uber/cadence/.gen/go/shared" @@ -140,9 +138,9 @@ func newTaskListManager( e *matchingEngineImpl, taskList *taskListID, taskListKind *s.TaskListKind, config *Config, ) taskListManager { dPtr := _defaultTaskDispatchRPS - cnst := make(map[dynamicconfig.ConstraintKey]interface{}) - cnst[dynamicconfig.TaskListName] = taskList.taskListName - rl := newRateLimiter(&dPtr, _defaultTaskDispatchRPSTTL, config.MinTaskThrottlingBurstSize(cnst)) + rl := newRateLimiter( + &dPtr, _defaultTaskDispatchRPSTTL, config.MinTaskThrottlingBurstSize(taskList.taskListName), + ) return newTaskListManagerWithRateLimiter(e, taskList, taskListKind, config, rl) }