Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow MaxConcurrentWorkflowTaskPollers to be set to 1 #727

Merged
merged 3 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/internal_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,13 @@ func NewAggregatedWorker(client *WorkflowClient, taskQueue string, options Worke
}
backgroundActivityContext, backgroundActivityContextCancel := context.WithCancel(ctx)

// If max-concurrent workflow pollers is 1, the worker will only do
// sticky-queue requests and never regular-queue requests. We disallow the
// value of 1 here.
if options.MaxConcurrentWorkflowTaskPollers == 1 {
panic("cannot set MaxConcurrentWorkflowTaskPollers to 1")
}

cache := NewWorkerCache()
workerParams := workerExecutionParameters{
Namespace: client.namespace,
Expand Down
6 changes: 6 additions & 0 deletions internal/internal_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,12 @@ func TestActivityNilArgs(t *testing.T) {
require.Equal(t, nilErr, reflectResults[0].Interface())
}

func TestWorkerOptionInvalid(t *testing.T) {
require.Panics(t, func() {
NewAggregatedWorker(&WorkflowClient{}, "worker-options-tq", WorkerOptions{MaxConcurrentWorkflowTaskPollers: 1})
})
}

func TestWorkerOptionDefaults(t *testing.T) {
client := &WorkflowClient{}
taskQueue := "worker-options-tq"
Expand Down
4 changes: 3 additions & 1 deletion internal/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ type (

// Optional: Sets the maximum number of goroutines that will concurrently poll the
// temporal-server to retrieve workflow tasks. Changing this value will affect the
// rate at which the worker is able to consume tasks from a task queue.
// rate at which the worker is able to consume tasks from a task queue. Due to
// internal logic where pollers alternate between stick and non-sticky queues, this
// value cannot be 1 and will panic if set to that value.
// default: 2
MaxConcurrentWorkflowTaskPollers int

Expand Down