@@ -70,7 +70,7 @@ func (b *mysqlBackend) CreateWorkflowInstance(ctx context.Context, m history.Wor
70
70
}
71
71
72
72
// Initial history is empty, store only new events
73
- if err := insertNewEvents (ctx , tx , m .WorkflowInstance .GetInstanceID () , []history.Event {m .HistoryEvent }); err != nil {
73
+ if err := insertNewEvents (ctx , tx , m .WorkflowInstance .InstanceID , []history.Event {m .HistoryEvent }); err != nil {
74
74
return errors .Wrap (err , "could not insert new event" )
75
75
}
76
76
@@ -81,14 +81,14 @@ func (b *mysqlBackend) CreateWorkflowInstance(ctx context.Context, m history.Wor
81
81
return nil
82
82
}
83
83
84
- func (b * mysqlBackend ) CancelWorkflowInstance (ctx context.Context , instance workflow.Instance ) error {
84
+ func (b * mysqlBackend ) CancelWorkflowInstance (ctx context.Context , instance * workflow.Instance ) error {
85
85
tx , err := b .db .BeginTx (ctx , nil )
86
86
if err != nil {
87
87
return err
88
88
}
89
89
defer tx .Rollback ()
90
90
91
- instanceID := instance .GetInstanceID ()
91
+ instanceID := instance .InstanceID
92
92
93
93
// Cancel workflow instance
94
94
if err := insertNewEvents (ctx , tx , instanceID , []history.Event {history .NewWorkflowCancellationEvent (time .Now ())}); err != nil {
@@ -120,7 +120,7 @@ func (b *mysqlBackend) CancelWorkflowInstance(ctx context.Context, instance work
120
120
return tx .Commit ()
121
121
}
122
122
123
- func (b * mysqlBackend ) GetWorkflowInstanceHistory (ctx context.Context , instance workflow.Instance ) ([]history.Event , error ) {
123
+ func (b * mysqlBackend ) GetWorkflowInstanceHistory (ctx context.Context , instance * workflow.Instance ) ([]history.Event , error ) {
124
124
tx , err := b .db .BeginTx (ctx , nil )
125
125
if err != nil {
126
126
return nil , err
@@ -130,7 +130,7 @@ func (b *mysqlBackend) GetWorkflowInstanceHistory(ctx context.Context, instance
130
130
historyEvents , err := tx .QueryContext (
131
131
ctx ,
132
132
"SELECT event_id, instance_id, event_type, timestamp, schedule_event_id, attributes, visible_at FROM `history` WHERE instance_id = ? ORDER BY id" ,
133
- instance .GetInstanceID () ,
133
+ instance .InstanceID ,
134
134
)
135
135
if err != nil {
136
136
return nil , errors .Wrap (err , "could not get history" )
@@ -169,12 +169,12 @@ func (b *mysqlBackend) GetWorkflowInstanceHistory(ctx context.Context, instance
169
169
return h , nil
170
170
}
171
171
172
- func (b * mysqlBackend ) GetWorkflowInstanceState (ctx context.Context , instance workflow.Instance ) (backend.WorkflowState , error ) {
172
+ func (b * mysqlBackend ) GetWorkflowInstanceState (ctx context.Context , instance * workflow.Instance ) (backend.WorkflowState , error ) {
173
173
row := b .db .QueryRowContext (
174
174
ctx ,
175
175
"SELECT completed_at FROM instances WHERE instance_id = ? AND execution_id = ?" ,
176
- instance .GetInstanceID () ,
177
- instance .GetExecutionID () ,
176
+ instance .InstanceID ,
177
+ instance .ExecutionID ,
178
178
)
179
179
180
180
var completedAt sql.NullTime
@@ -191,22 +191,22 @@ func (b *mysqlBackend) GetWorkflowInstanceState(ctx context.Context, instance wo
191
191
return backend .WorkflowStateActive , nil
192
192
}
193
193
194
- func createInstance (ctx context.Context , tx * sql.Tx , wfi workflow.Instance , ignoreDuplicate bool ) error {
194
+ func createInstance (ctx context.Context , tx * sql.Tx , wfi * workflow.Instance , ignoreDuplicate bool ) error {
195
195
var parentInstanceID * string
196
196
var parentEventID * int
197
197
if wfi .SubWorkflow () {
198
- i := wfi .ParentInstance (). GetInstanceID ()
198
+ i := wfi .ParentInstanceID
199
199
parentInstanceID = & i
200
200
201
- n := wfi .ParentEventID ()
201
+ n := wfi .ParentEventID
202
202
parentEventID = & n
203
203
}
204
204
205
205
res , err := tx .ExecContext (
206
206
ctx ,
207
207
"INSERT IGNORE INTO `instances` (instance_id, execution_id, parent_instance_id, parent_schedule_event_id) VALUES (?, ?, ?, ?)" ,
208
- wfi .GetInstanceID () ,
209
- wfi .GetExecutionID () ,
208
+ wfi .InstanceID ,
209
+ wfi .ExecutionID ,
210
210
parentInstanceID ,
211
211
parentEventID ,
212
212
)
@@ -316,15 +316,15 @@ func (b *mysqlBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, err
316
316
kind = task .Continuation
317
317
}
318
318
319
- var wfi workflow.Instance
319
+ var wfi * workflow.Instance
320
320
if parentInstanceID != nil {
321
- wfi = core .NewSubWorkflowInstance (instanceID , executionID , core . NewWorkflowInstance ( * parentInstanceID , "" ) , * parentEventID )
321
+ wfi = core .NewSubWorkflowInstance (instanceID , executionID , * parentInstanceID , * parentEventID )
322
322
} else {
323
323
wfi = core .NewWorkflowInstance (instanceID , executionID )
324
324
}
325
325
326
326
t := & task.Workflow {
327
- ID : wfi .GetInstanceID () ,
327
+ ID : wfi .InstanceID ,
328
328
WorkflowInstance : wfi ,
329
329
NewEvents : []history.Event {},
330
330
History : []history.Event {},
@@ -451,7 +451,7 @@ func (b *mysqlBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, err
451
451
func (b * mysqlBackend ) CompleteWorkflowTask (
452
452
ctx context.Context ,
453
453
taskID string ,
454
- instance workflow.Instance ,
454
+ instance * workflow.Instance ,
455
455
state backend.WorkflowState ,
456
456
executedEvents []history.Event ,
457
457
activityEvents []history.Event ,
@@ -477,8 +477,8 @@ func (b *mysqlBackend) CompleteWorkflowTask(
477
477
`UPDATE instances SET locked_until = NULL, sticky_until = ?, completed_at = ? WHERE instance_id = ? AND execution_id = ? AND worker = ?` ,
478
478
time .Now ().Add (b .options .StickyTimeout ),
479
479
completedAt ,
480
- instance .GetInstanceID () ,
481
- instance .GetExecutionID () ,
480
+ instance .InstanceID ,
481
+ instance .ExecutionID ,
482
482
b .workerName ,
483
483
)
484
484
if err != nil {
@@ -495,7 +495,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
495
495
// Remove handled events from task
496
496
if len (executedEvents ) > 0 {
497
497
args := make ([]interface {}, 0 , len (executedEvents )+ 1 )
498
- args = append (args , instance .GetInstanceID () )
498
+ args = append (args , instance .InstanceID )
499
499
for _ , e := range executedEvents {
500
500
args = append (args , e .ID )
501
501
}
@@ -510,19 +510,19 @@ func (b *mysqlBackend) CompleteWorkflowTask(
510
510
}
511
511
512
512
// Insert new events generated during this workflow execution to the history
513
- if err := insertHistoryEvents (ctx , tx , instance .GetInstanceID () , executedEvents ); err != nil {
513
+ if err := insertHistoryEvents (ctx , tx , instance .InstanceID , executedEvents ); err != nil {
514
514
return errors .Wrap (err , "could not insert new history events" )
515
515
}
516
516
517
517
// Schedule activities
518
518
for _ , e := range activityEvents {
519
- if err := scheduleActivity (ctx , tx , instance .GetInstanceID () , instance .GetExecutionID () , e ); err != nil {
519
+ if err := scheduleActivity (ctx , tx , instance .InstanceID , instance .ExecutionID , e ); err != nil {
520
520
return errors .Wrap (err , "could not schedule activity" )
521
521
}
522
522
}
523
523
524
524
// Insert new workflow events
525
- groupedEvents := make (map [workflow.Instance ][]history.Event )
525
+ groupedEvents := make (map [* workflow.Instance ][]history.Event )
526
526
for _ , m := range workflowEvents {
527
527
if _ , ok := groupedEvents [m .WorkflowInstance ]; ! ok {
528
528
groupedEvents [m .WorkflowInstance ] = []history.Event {}
@@ -532,14 +532,14 @@ func (b *mysqlBackend) CompleteWorkflowTask(
532
532
}
533
533
534
534
for targetInstance , events := range groupedEvents {
535
- if targetInstance .GetInstanceID () != instance .GetInstanceID () {
535
+ if targetInstance .InstanceID != instance .InstanceID {
536
536
// Create new instance
537
537
if err := createInstance (ctx , tx , targetInstance , true ); err != nil {
538
538
return err
539
539
}
540
540
}
541
541
542
- if err := insertNewEvents (ctx , tx , targetInstance .GetInstanceID () , events ); err != nil {
542
+ if err := insertNewEvents (ctx , tx , targetInstance .InstanceID , events ); err != nil {
543
543
return errors .Wrap (err , "could not insert messages" )
544
544
}
545
545
}
@@ -551,7 +551,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
551
551
return nil
552
552
}
553
553
554
- func (b * mysqlBackend ) ExtendWorkflowTask (ctx context.Context , taskID string , instance core.WorkflowInstance ) error {
554
+ func (b * mysqlBackend ) ExtendWorkflowTask (ctx context.Context , taskID string , instance * core.WorkflowInstance ) error {
555
555
tx , err := b .db .BeginTx (ctx , nil )
556
556
if err != nil {
557
557
return err
@@ -563,8 +563,8 @@ func (b *mysqlBackend) ExtendWorkflowTask(ctx context.Context, taskID string, in
563
563
ctx ,
564
564
`UPDATE instances SET locked_until = ? WHERE instance_id = ? AND execution_id = ? AND worker = ?` ,
565
565
until ,
566
- instance .GetInstanceID () ,
567
- instance .GetExecutionID () ,
566
+ instance .InstanceID ,
567
+ instance .ExecutionID ,
568
568
b .workerName ,
569
569
)
570
570
if err != nil {
@@ -646,7 +646,7 @@ func (b *mysqlBackend) GetActivityTask(ctx context.Context) (*task.Activity, err
646
646
}
647
647
648
648
// CompleteActivityTask completes a activity task retrieved using GetActivityTask
649
- func (b * mysqlBackend ) CompleteActivityTask (ctx context.Context , instance workflow.Instance , id string , event history.Event ) error {
649
+ func (b * mysqlBackend ) CompleteActivityTask (ctx context.Context , instance * workflow.Instance , id string , event history.Event ) error {
650
650
tx , err := b .db .BeginTx (ctx , & sql.TxOptions {
651
651
Isolation : sql .LevelReadCommitted ,
652
652
})
@@ -660,8 +660,8 @@ func (b *mysqlBackend) CompleteActivityTask(ctx context.Context, instance workfl
660
660
ctx ,
661
661
`DELETE FROM activities WHERE activity_id = ? AND instance_id = ? AND execution_id = ? AND worker = ?` ,
662
662
id ,
663
- instance .GetInstanceID () ,
664
- instance .GetExecutionID () ,
663
+ instance .InstanceID ,
664
+ instance .ExecutionID ,
665
665
b .workerName ,
666
666
); err != nil {
667
667
return errors .Wrap (err , "could not complete activity" )
@@ -677,7 +677,7 @@ func (b *mysqlBackend) CompleteActivityTask(ctx context.Context, instance workfl
677
677
}
678
678
679
679
// Insert new event generated during this workflow execution
680
- if err := insertNewEvents (ctx , tx , instance .GetInstanceID () , []history.Event {event }); err != nil {
680
+ if err := insertNewEvents (ctx , tx , instance .InstanceID , []history.Event {event }); err != nil {
681
681
return errors .Wrap (err , "could not insert new events for completed activity" )
682
682
}
683
683
0 commit comments