@@ -29,15 +29,11 @@ type monoprocessBackend struct {
29
29
// worked on. Note that only one worker will be notified.
30
30
// IMPORTANT: Only use this backend if the backend and worker are running in the
31
31
// same process.
32
- func NewMonoprocessBackend (b backend.Backend , signalBufferSize int , signalTimeout time.Duration ) * monoprocessBackend {
33
- if signalTimeout <= 0 {
34
- signalTimeout = time .Second // default
35
- }
32
+ func NewMonoprocessBackend (b backend.Backend ) * monoprocessBackend {
36
33
mb := & monoprocessBackend {
37
34
Backend : b ,
38
- workflowSignal : make (chan struct {}, signalBufferSize ),
39
- activitySignal : make (chan struct {}, signalBufferSize ),
40
- signalTimeout : signalTimeout ,
35
+ workflowSignal : make (chan struct {}, 1 ),
36
+ activitySignal : make (chan struct {}, 1 ),
41
37
logger : b .Logger (),
42
38
}
43
39
return mb
@@ -165,32 +161,20 @@ func (b *monoprocessBackend) SignalWorkflow(ctx context.Context, instanceID stri
165
161
return nil
166
162
}
167
163
168
- func (b * monoprocessBackend ) notifyActivityWorker (ctx context.Context ) bool {
169
- ctx , cancel := context .WithTimeout (ctx , b .signalTimeout )
170
- defer cancel ()
164
+ func (b * monoprocessBackend ) notifyActivityWorker (ctx context.Context ) {
171
165
select {
172
- case <- ctx .Done ():
173
- // we didn't manage to notify the worker that there is a new task, it
174
- // will pick it up after the poll timeout
175
- b .logger .DebugContext (ctx , "failed to signal activity task to worker" , "reason" , ctx .Err ())
176
- return false
177
166
case b .activitySignal <- struct {}{}:
178
167
b .logger .DebugContext (ctx , "signalled a new activity task to worker" )
179
- return true
168
+ default :
169
+ // the signal channel already contains a signal, no need to add another
180
170
}
181
171
}
182
172
183
- func (b * monoprocessBackend ) notifyWorkflowWorker (ctx context.Context ) bool {
184
- ctx , cancel := context .WithTimeout (ctx , b .signalTimeout )
185
- defer cancel ()
173
+ func (b * monoprocessBackend ) notifyWorkflowWorker (ctx context.Context ) {
186
174
select {
187
- case <- ctx .Done ():
188
- // we didn't manage to notify the worker that there is a new task, it
189
- // will pick it up after the poll timeout
190
- b .logger .DebugContext (ctx , "failed to signal workflow task to worker" , "reason" , ctx .Err ())
191
- return false
192
175
case b .workflowSignal <- struct {}{}:
193
176
b .logger .DebugContext (ctx , "signalled a new workflow task to worker" )
194
- return true
177
+ default :
178
+ // the signal channel already contains a signal, no need to add another
195
179
}
196
180
}
0 commit comments