From bcb1d8cc1a7b762fe855b4509b4ec3c211dfc617 Mon Sep 17 00:00:00 2001 From: lwolczynski <54366429+lwolczynski@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:53:58 -0500 Subject: [PATCH] IWF-233: Override WorkerOptions default values (#474) --- service/interpreter/cadence/worker.go | 17 +++++++++++++---- service/interpreter/temporal/worker.go | 21 +++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/service/interpreter/cadence/worker.go b/service/interpreter/cadence/worker.go index dbb0dcd6..dc22ad73 100644 --- a/service/interpreter/cadence/worker.go +++ b/service/interpreter/cadence/worker.go @@ -39,13 +39,22 @@ func (iw *InterpreterWorker) Close() { func (iw *InterpreterWorker) Start() { config := env.GetSharedConfig() - options := worker.Options{ - MaxConcurrentActivityTaskPollers: 10, - MaxConcurrentDecisionTaskPollers: 10, - } + var options worker.Options + if config.Interpreter.Cadence != nil && config.Interpreter.Cadence.WorkerOptions != nil { options = *config.Interpreter.Cadence.WorkerOptions } + + // override default + if options.MaxConcurrentActivityTaskPollers == 0 { + options.MaxConcurrentActivityTaskPollers = 10 + } + + // override default + if options.MaxConcurrentDecisionTaskPollers == 0 { + options.MaxConcurrentDecisionTaskPollers = 10 + } + iw.worker = worker.New(iw.service, iw.domain, iw.tasklist, options) worker.EnableVerboseLogging(config.Interpreter.VerboseDebug) diff --git a/service/interpreter/temporal/worker.go b/service/interpreter/temporal/worker.go index f43c98a1..17bf0e62 100644 --- a/service/interpreter/temporal/worker.go +++ b/service/interpreter/temporal/worker.go @@ -37,15 +37,24 @@ func (iw *InterpreterWorker) Close() { func (iw *InterpreterWorker) Start() { config := env.GetSharedConfig() - options := worker.Options{ - MaxConcurrentActivityTaskPollers: 10, - // TODO: this cannot be too small otherwise the persistence_test for continueAsNew will fail, probably a bug in Temporal goSDK. - // It seems work as "parallelism" of something... need to report a bug ticket... - MaxConcurrentWorkflowTaskPollers: 10, - } + var options worker.Options + if config.Interpreter.Temporal != nil && config.Interpreter.Temporal.WorkerOptions != nil { options = *config.Interpreter.Temporal.WorkerOptions } + + // override default + if options.MaxConcurrentActivityTaskPollers == 0 { + options.MaxConcurrentActivityTaskPollers = 10 + } + + // override default + if options.MaxConcurrentWorkflowTaskPollers == 0 { + // TODO: this cannot be too small otherwise the persistence_test for continueAsNew will fail, probably a bug in Temporal goSDK. + // It seems work as "parallelism" of something... need to report a bug ticket... + options.MaxConcurrentWorkflowTaskPollers = 10 + } + iw.worker = worker.New(iw.temporalClient, iw.taskQueue, options) worker.EnableVerboseLogging(config.Interpreter.VerboseDebug)