Skip to content

Commit

Permalink
refactor get property with domain filter
Browse files Browse the repository at this point in the history
  • Loading branch information
vancexu committed Jun 14, 2018
1 parent c3fac5d commit 55d4f5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions common/service/dynamicconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ func (c *Collection) GetBoolProperty(key Key, defaultValue bool) BoolPropertyFn
return val
}
}

// GetIntPropertyWithDomainFilter return int value from dynamic config with domain filter
func GetIntPropertyWithDomainFilter(fn IntPropertyFn, domain string) int {
return fn(DomainFilter(domain))
}
14 changes: 7 additions & 7 deletions service/frontend/workflowHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,8 +1339,8 @@ func (wh *WorkflowHandler) GetWorkflowExecutionHistory(
}

if getRequest.GetMaximumPageSize() <= 0 {
domainFilter := dynamicconfig.DomainFilter(getRequest.GetDomain())
getRequest.MaximumPageSize = common.Int32Ptr(int32(wh.config.HistoryMaxPageSize(domainFilter)))
getRequest.MaximumPageSize = common.Int32Ptr(int32(
dynamicconfig.GetIntPropertyWithDomainFilter(wh.config.HistoryMaxPageSize, getRequest.GetDomain())))
}

domainID, err := wh.domainCache.GetDomainID(getRequest.GetDomain())
Expand Down Expand Up @@ -1703,8 +1703,8 @@ func (wh *WorkflowHandler) ListOpenWorkflowExecutions(ctx context.Context,
}

if listRequest.GetMaximumPageSize() <= 0 {
domainFilter := dynamicconfig.DomainFilter(listRequest.GetDomain())
listRequest.MaximumPageSize = common.Int32Ptr(int32(wh.config.VisibilityMaxPageSize(domainFilter)))
listRequest.MaximumPageSize = common.Int32Ptr(int32(
dynamicconfig.GetIntPropertyWithDomainFilter(wh.config.VisibilityMaxPageSize, listRequest.GetDomain())))
}

domainID, err := wh.domainCache.GetDomainID(listRequest.GetDomain())
Expand Down Expand Up @@ -1795,8 +1795,8 @@ func (wh *WorkflowHandler) ListClosedWorkflowExecutions(ctx context.Context,
}

if listRequest.GetMaximumPageSize() <= 0 {
domainFilter := dynamicconfig.DomainFilter(listRequest.GetDomain())
listRequest.MaximumPageSize = common.Int32Ptr(int32(wh.config.VisibilityMaxPageSize(domainFilter)))
listRequest.MaximumPageSize = common.Int32Ptr(int32(
dynamicconfig.GetIntPropertyWithDomainFilter(wh.config.VisibilityMaxPageSize, listRequest.GetDomain())))
}

domainID, err := wh.domainCache.GetDomainID(listRequest.GetDomain())
Expand Down Expand Up @@ -2293,7 +2293,7 @@ func (wh *WorkflowHandler) createPollForDecisionTaskResponse(ctx context.Context
*matchingResp.WorkflowExecution,
firstEventID,
nextEventID,
int32(wh.config.HistoryMaxPageSize(dynamicconfig.DomainFilter(domain.GetInfo().Name))),
int32(dynamicconfig.GetIntPropertyWithDomainFilter(wh.config.HistoryMaxPageSize, domain.GetInfo().Name)),
nil,
matchingResp.DecisionInfo)
if err != nil {
Expand Down

0 comments on commit 55d4f5b

Please sign in to comment.