@@ -38,7 +38,7 @@ type executor struct {
38
38
39
39
func NewExecutor (registry * Registry , instance core.WorkflowInstance , clock clock.Clock ) (WorkflowExecutor , error ) {
40
40
state := newWorkflowState (instance , clock )
41
- wfCtx , cancel := sync .WithCancel (withWfState (sync .Background (), state ))
41
+ wfCtx , cancel := sync .WithCancel (WithWorkflowState (sync .Background (), state ))
42
42
43
43
return & executor {
44
44
registry : registry ,
@@ -60,7 +60,7 @@ func (e *executor) ExecuteTask(ctx context.Context, t *task.Workflow) ([]history
60
60
}
61
61
62
62
// Clear commands from previous executions
63
- e .workflowState .clearCommands ()
63
+ e .workflowState .ClearCommands ()
64
64
} else {
65
65
// Replay history
66
66
e .workflowState .setReplaying (true )
@@ -204,7 +204,7 @@ func (e *executor) handleWorkflowTaskStarted(event history.Event, a *history.Wor
204
204
}
205
205
206
206
func (e * executor ) handleActivityScheduled (event history.Event , a * history.ActivityScheduledAttributes ) error {
207
- c := e .workflowState .removeCommandByEventID (event .ScheduleEventID )
207
+ c := e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
208
208
if c != nil {
209
209
// Ensure the same activity is scheduled again
210
210
ca := c .Attr .(* command.ScheduleActivityTaskCommandAttr )
@@ -222,7 +222,7 @@ func (e *executor) handleActivityCompleted(event history.Event, a *history.Activ
222
222
return nil
223
223
}
224
224
225
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
225
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
226
226
f .Set (a .Result , nil )
227
227
228
228
return e .workflow .Continue (e .workflowCtx )
@@ -234,15 +234,15 @@ func (e *executor) handleActivityFailed(event history.Event, a *history.Activity
234
234
return errors .New ("no pending future found for activity failed event" )
235
235
}
236
236
237
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
237
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
238
238
239
239
f .Set (nil , errors .New (a .Reason ))
240
240
241
241
return e .workflow .Continue (e .workflowCtx )
242
242
}
243
243
244
244
func (e * executor ) handleTimerScheduled (event history.Event , a * history.TimerScheduledAttributes ) error {
245
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
245
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
246
246
247
247
return nil
248
248
}
@@ -254,15 +254,15 @@ func (e *executor) handleTimerFired(event history.Event, a *history.TimerFiredAt
254
254
return nil
255
255
}
256
256
257
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
257
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
258
258
259
259
f .Set (nil , nil )
260
260
261
261
return e .workflow .Continue (e .workflowCtx )
262
262
}
263
263
264
264
func (e * executor ) handleSubWorkflowScheduled (event history.Event , a * history.SubWorkflowScheduledAttributes ) error {
265
- c := e .workflowState .removeCommandByEventID (event .ScheduleEventID )
265
+ c := e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
266
266
if c != nil {
267
267
ca := c .Attr .(* command.ScheduleSubWorkflowCommandAttr )
268
268
if a .Name != ca .Name {
@@ -279,7 +279,7 @@ func (e *executor) handleSubWorkflowFailed(event history.Event, a *history.SubWo
279
279
return errors .New ("no pending future found for sub workflow failed event" )
280
280
}
281
281
282
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
282
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
283
283
284
284
f .Set (nil , errors .New (a .Error ))
285
285
@@ -292,7 +292,7 @@ func (e *executor) handleSubWorkflowCompleted(event history.Event, a *history.Su
292
292
return errors .New ("no pending future found for sub workflow completed event" )
293
293
}
294
294
295
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
295
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
296
296
297
297
f .Set (a .Result , nil )
298
298
@@ -301,10 +301,10 @@ func (e *executor) handleSubWorkflowCompleted(event history.Event, a *history.Su
301
301
302
302
func (e * executor ) handleSignalReceived (event history.Event , a * history.SignalReceivedAttributes ) error {
303
303
// Send signal to workflow channel
304
- sc := e .workflowState .getSignalChannel (a .Name )
304
+ sc := e .workflowState .GetSignalChannel (a .Name )
305
305
sc .SendNonblocking (e .workflowCtx , a .Arg )
306
306
307
- e .workflowState .removeCommandByEventID (event .ScheduleEventID )
307
+ e .workflowState .RemoveCommandByEventID (event .ScheduleEventID )
308
308
309
309
return e .workflow .Continue (e .workflowCtx )
310
310
}
@@ -325,7 +325,7 @@ func (e *executor) workflowCompleted(result payload.Payload, err error) error {
325
325
e .workflowState .scheduleEventID ++
326
326
327
327
cmd := command .NewCompleteWorkflowCommand (eventId , result , err )
328
- e .workflowState .addCommand (& cmd )
328
+ e .workflowState .AddCommand (& cmd )
329
329
330
330
return nil
331
331
}
0 commit comments