@@ -33,7 +33,6 @@ import (
3333 "strconv"
3434 "strings"
3535 "sync"
36- "time"
3736
3837 "github.com/apache/thrift/lib/go/thrift"
3938 "github.com/uber-go/tally"
@@ -107,11 +106,8 @@ type (
107106 // Defines how many concurrent executions for task list by this worker.
108107 ConcurrentActivityExecutionSize int
109108
110- // Defines rate limiting on number of activity tasks that can be executed per MaxActivityExecutionRateRefreshDuration.
111- MaxActivityExecutionRate int
112-
113- // Defines refresh duration for rate limit. If not specified, it uses 1s as default.
114- MaxActivityExecutionRateRefreshDuration time.Duration
109+ // Defines rate limiting on number of activity tasks that can be executed per second.
110+ MaxActivityExecutionPerSecond float64
115111
116112 // User can provide an identity for the debuggability. If not provided the framework has
117113 // a default option.
@@ -226,13 +222,12 @@ func newWorkflowTaskWorkerInternal(
226222 params ,
227223 )
228224 worker := newBaseWorker (baseWorkerOptions {
229- pollerCount : params .ConcurrentPollRoutineSize ,
230- maxConcurrentTask : defaultMaxConcurrentWorkflowExecutionSize ,
231- maxTaskRate : defaultMaxWorkflowExecutionRate ,
232- maxTaskRateRefreshDuration : time .Second ,
233- taskWorker : poller ,
234- identity : params .Identity ,
235- workerType : "DecisionWorker" },
225+ pollerCount : params .ConcurrentPollRoutineSize ,
226+ maxConcurrentTask : defaultMaxConcurrentWorkflowExecutionSize ,
227+ maxTaskPerSecond : defaultMaxWorkflowExecutionRate ,
228+ taskWorker : poller ,
229+ identity : params .Identity ,
230+ workerType : "DecisionWorker" },
236231 params .Logger ,
237232 params .MetricsScope ,
238233 )
@@ -306,13 +301,12 @@ func newActivityTaskWorker(
306301
307302 base := newBaseWorker (
308303 baseWorkerOptions {
309- pollerCount : workerParams .ConcurrentPollRoutineSize ,
310- maxConcurrentTask : workerParams .ConcurrentActivityExecutionSize ,
311- maxTaskRate : workerParams .MaxActivityExecutionRate ,
312- maxTaskRateRefreshDuration : workerParams .MaxActivityExecutionRateRefreshDuration ,
313- taskWorker : poller ,
314- identity : workerParams .Identity ,
315- workerType : "ActivityWorker" ,
304+ pollerCount : workerParams .ConcurrentPollRoutineSize ,
305+ maxConcurrentTask : workerParams .ConcurrentActivityExecutionSize ,
306+ maxTaskPerSecond : workerParams .MaxActivityExecutionPerSecond ,
307+ taskWorker : poller ,
308+ identity : workerParams .Identity ,
309+ workerType : "ActivityWorker" ,
316310 },
317311 workerParams .Logger ,
318312 workerParams .MetricsScope ,
@@ -1005,16 +999,15 @@ func newAggregatedWorker(
1005999) (worker Worker ) {
10061000 wOptions := fillWorkerOptionsDefaults (options )
10071001 workerParams := workerExecutionParameters {
1008- TaskList : taskList ,
1009- ConcurrentPollRoutineSize : defaultConcurrentPollRoutineSize ,
1010- ConcurrentActivityExecutionSize : wOptions .MaxConcurrentActivityExecutionSize ,
1011- MaxActivityExecutionRate : wOptions .MaxActivityExecutionRate ,
1012- MaxActivityExecutionRateRefreshDuration : wOptions .MaxActivityExecutionRateRefreshDuration ,
1013- Identity : wOptions .Identity ,
1014- MetricsScope : wOptions .MetricsScope ,
1015- Logger : wOptions .Logger ,
1016- EnableLoggingInReplay : wOptions .EnableLoggingInReplay ,
1017- UserContext : wOptions .BackgroundActivityContext ,
1002+ TaskList : taskList ,
1003+ ConcurrentPollRoutineSize : defaultConcurrentPollRoutineSize ,
1004+ ConcurrentActivityExecutionSize : wOptions .MaxConcurrentActivityExecutionSize ,
1005+ MaxActivityExecutionPerSecond : wOptions .MaxActivityExecutionPerSecond ,
1006+ Identity : wOptions .Identity ,
1007+ MetricsScope : wOptions .MetricsScope ,
1008+ Logger : wOptions .Logger ,
1009+ EnableLoggingInReplay : wOptions .EnableLoggingInReplay ,
1010+ UserContext : wOptions .BackgroundActivityContext ,
10181011 }
10191012
10201013 ensureRequiredParams (& workerParams )
@@ -1227,11 +1220,8 @@ func fillWorkerOptionsDefaults(options WorkerOptions) WorkerOptions {
12271220 if options .MaxConcurrentActivityExecutionSize == 0 {
12281221 options .MaxConcurrentActivityExecutionSize = defaultMaxConcurrentActivityExecutionSize
12291222 }
1230- if options .MaxActivityExecutionRate == 0 {
1231- options .MaxActivityExecutionRate = defaultMaxActivityExecutionRate
1232- }
1233- if options .MaxActivityExecutionRateRefreshDuration == 0 {
1234- options .MaxActivityExecutionRateRefreshDuration = time .Second
1223+ if options .MaxActivityExecutionPerSecond == 0 {
1224+ options .MaxActivityExecutionPerSecond = defaultMaxActivityExecutionRate
12351225 }
12361226 return options
12371227}
0 commit comments