@@ -94,20 +94,20 @@ func (b *monoprocessBackend) CompleteWorkflowTask(
94
94
if err := b .Backend .CompleteWorkflowTask (ctx , task , instance , state , executedEvents , activityEvents , timerEvents , workflowEvents ); err != nil {
95
95
return err
96
96
}
97
+
98
+ hasWorkflowTasks := false
99
+ hasActivityTasks := false
100
+
97
101
for _ , e := range executedEvents {
98
- if e .Type != history .EventType_WorkflowTaskStarted {
99
- continue
100
- }
101
- if ! b .notifyWorkflowWorker (ctx ) {
102
- break // no reason to notify more, queue is full
102
+ if e .Type == history .EventType_WorkflowTaskStarted {
103
+ hasWorkflowTasks = true
104
+ break
103
105
}
104
106
}
105
107
for _ , e := range activityEvents {
106
- if e .Type != history .EventType_ActivityScheduled {
107
- continue
108
- }
109
- if ! b .notifyActivityWorker (ctx ) {
110
- break // no reason to notify more, queue is full
108
+ if e .Type == history .EventType_ActivityScheduled {
109
+ hasActivityTasks = true
110
+ break
111
111
}
112
112
}
113
113
for _ , e := range timerEvents {
@@ -123,15 +123,21 @@ func (b *monoprocessBackend) CompleteWorkflowTask(
123
123
time .AfterFunc (attr .At .Sub (time .Now ()), func () { b .notifyWorkflowWorker (context .Background ()) })
124
124
}
125
125
for _ , e := range workflowEvents {
126
- if e .HistoryEvent .Type != history .EventType_WorkflowExecutionStarted &&
127
- e .HistoryEvent .Type != history .EventType_SubWorkflowCompleted &&
128
- e .HistoryEvent .Type != history .EventType_WorkflowExecutionCanceled {
129
- continue
130
- }
131
- if ! b .notifyWorkflowWorker (ctx ) {
132
- break // no reason to notify more, queue is full
126
+ if e .HistoryEvent .Type == history .EventType_WorkflowExecutionStarted ||
127
+ e .HistoryEvent .Type == history .EventType_SubWorkflowCompleted ||
128
+ e .HistoryEvent .Type == history .EventType_WorkflowExecutionCanceled {
129
+ hasWorkflowTasks = true
130
+ break
133
131
}
134
132
}
133
+
134
+ // notify workers about potential new tasks
135
+ if hasWorkflowTasks {
136
+ b .notifyWorkflowWorker (ctx )
137
+ }
138
+ if hasActivityTasks {
139
+ b .notifyActivityWorker (ctx )
140
+ }
135
141
return nil
136
142
}
137
143
0 commit comments