Skip to content

Commit 4a7489d

Browse files
authored
Merge branch 'main' into copilot/fix-386
2 parents e8e7c9e + 7973e53 commit 4a7489d

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

worker/workflow_orchestrator.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ func NewWorkflowOrchestrator(backend backend.Backend, options *Options) *Workflo
3030
orchestratorOptions := *options
3131
orchestratorOptions.SingleWorkerMode = true
3232

33+
// Set default pollers to 1 for orchestrator mode (unless explicitly overridden)
34+
if orchestratorOptions.WorkflowPollers == DefaultOptions.WorkflowPollers {
35+
orchestratorOptions.WorkflowPollers = 1
36+
}
37+
if orchestratorOptions.ActivityPollers == DefaultOptions.ActivityPollers {
38+
orchestratorOptions.ActivityPollers = 1
39+
}
40+
3341
// Create registry that will be shared between worker and orchestrator
3442
reg := registry.New()
3543

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package worker
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func TestWorkflowOrchestrator_PollerDefaults(t *testing.T) {
10+
tests := []struct {
11+
name string
12+
inputOptions *Options
13+
expectedWorkflowPollers int
14+
expectedActivityPollers int
15+
expectedSingleWorkerMode bool
16+
}{
17+
{
18+
name: "nil options should use 1 poller for orchestrator",
19+
inputOptions: nil,
20+
expectedWorkflowPollers: 1,
21+
expectedActivityPollers: 1,
22+
expectedSingleWorkerMode: true,
23+
},
24+
{
25+
name: "default options should change to 1 poller for orchestrator",
26+
inputOptions: &Options{
27+
WorkflowWorkerOptions: WorkflowWorkerOptions{
28+
WorkflowPollers: DefaultOptions.WorkflowPollers, // Should be 2
29+
},
30+
ActivityWorkerOptions: ActivityWorkerOptions{
31+
ActivityPollers: DefaultOptions.ActivityPollers, // Should be 2
32+
},
33+
},
34+
expectedWorkflowPollers: 1,
35+
expectedActivityPollers: 1,
36+
expectedSingleWorkerMode: true,
37+
},
38+
{
39+
name: "custom options should be preserved",
40+
inputOptions: &Options{
41+
WorkflowWorkerOptions: WorkflowWorkerOptions{
42+
WorkflowPollers: 3,
43+
},
44+
ActivityWorkerOptions: ActivityWorkerOptions{
45+
ActivityPollers: 5,
46+
},
47+
},
48+
expectedWorkflowPollers: 3,
49+
expectedActivityPollers: 5,
50+
expectedSingleWorkerMode: true,
51+
},
52+
}
53+
54+
for _, tt := range tests {
55+
t.Run(tt.name, func(t *testing.T) {
56+
// Simulate the logic from NewWorkflowOrchestrator
57+
options := tt.inputOptions
58+
if options == nil {
59+
options = &DefaultOptions
60+
}
61+
62+
// Enable SingleWorkerMode automatically for the orchestrator
63+
orchestratorOptions := *options
64+
orchestratorOptions.SingleWorkerMode = true
65+
66+
// Set default pollers to 1 for orchestrator mode (unless explicitly overridden)
67+
if orchestratorOptions.WorkflowPollers == DefaultOptions.WorkflowPollers {
68+
orchestratorOptions.WorkflowPollers = 1
69+
}
70+
if orchestratorOptions.ActivityPollers == DefaultOptions.ActivityPollers {
71+
orchestratorOptions.ActivityPollers = 1
72+
}
73+
74+
// Verify the results
75+
require.Equal(t, tt.expectedWorkflowPollers, orchestratorOptions.WorkflowPollers)
76+
require.Equal(t, tt.expectedActivityPollers, orchestratorOptions.ActivityPollers)
77+
require.Equal(t, tt.expectedSingleWorkerMode, orchestratorOptions.SingleWorkerMode)
78+
})
79+
}
80+
}

0 commit comments

Comments
 (0)