@@ -63,7 +63,7 @@ type mysqlBackend struct {
63
63
}
64
64
65
65
// CreateWorkflowInstance creates a new workflow instance
66
- func (b * mysqlBackend ) CreateWorkflowInstance (ctx context.Context , instance * workflow.Instance , event history.Event ) error {
66
+ func (b * mysqlBackend ) CreateWorkflowInstance (ctx context.Context , instance * workflow.Instance , event * history.Event ) error {
67
67
tx , err := b .db .BeginTx (ctx , & sql.TxOptions {
68
68
Isolation : sql .LevelReadCommitted ,
69
69
})
@@ -78,7 +78,7 @@ func (b *mysqlBackend) CreateWorkflowInstance(ctx context.Context, instance *wor
78
78
}
79
79
80
80
// Initial history is empty, store only new events
81
- if err := insertPendingEvents (ctx , tx , instance .InstanceID , []history.Event {event }); err != nil {
81
+ if err := insertPendingEvents (ctx , tx , instance .InstanceID , []* history.Event {event }); err != nil {
82
82
return fmt .Errorf ("inserting new event: %w" , err )
83
83
}
84
84
@@ -127,14 +127,14 @@ func (b *mysqlBackend) CancelWorkflowInstance(ctx context.Context, instance *wor
127
127
return err
128
128
}
129
129
130
- if err := insertPendingEvents (ctx , tx , instanceID , []history.Event {* event }); err != nil {
130
+ if err := insertPendingEvents (ctx , tx , instanceID , []* history.Event {event }); err != nil {
131
131
return fmt .Errorf ("inserting cancellation event: %w" , err )
132
132
}
133
133
134
134
return tx .Commit ()
135
135
}
136
136
137
- func (b * mysqlBackend ) GetWorkflowInstanceHistory (ctx context.Context , instance * workflow.Instance , lastSequenceID * int64 ) ([]history.Event , error ) {
137
+ func (b * mysqlBackend ) GetWorkflowInstanceHistory (ctx context.Context , instance * workflow.Instance , lastSequenceID * int64 ) ([]* history.Event , error ) {
138
138
tx , err := b .db .BeginTx (ctx , nil )
139
139
if err != nil {
140
140
return nil , err
@@ -160,13 +160,13 @@ func (b *mysqlBackend) GetWorkflowInstanceHistory(ctx context.Context, instance
160
160
return nil , fmt .Errorf ("getting history: %w" , err )
161
161
}
162
162
163
- h := make ([]history.Event , 0 )
163
+ h := make ([]* history.Event , 0 )
164
164
165
165
for historyEvents .Next () {
166
166
var instanceID string
167
167
var attributes []byte
168
168
169
- historyEvent := history.Event {}
169
+ historyEvent := & history.Event {}
170
170
171
171
if err := historyEvents .Scan (
172
172
& historyEvent .ID ,
@@ -260,7 +260,7 @@ func createInstance(ctx context.Context, tx *sql.Tx, wfi *workflow.Instance, met
260
260
}
261
261
262
262
// SignalWorkflow signals a running workflow instance
263
- func (b * mysqlBackend ) SignalWorkflow (ctx context.Context , instanceID string , event history.Event ) error {
263
+ func (b * mysqlBackend ) SignalWorkflow (ctx context.Context , instanceID string , event * history.Event ) error {
264
264
tx , err := b .db .BeginTx (ctx , & sql.TxOptions {
265
265
Isolation : sql .LevelReadCommitted ,
266
266
})
@@ -275,7 +275,7 @@ func (b *mysqlBackend) SignalWorkflow(ctx context.Context, instanceID string, ev
275
275
return backend .ErrInstanceNotFound
276
276
}
277
277
278
- if err := insertPendingEvents (ctx , tx , instanceID , []history.Event {event }); err != nil {
278
+ if err := insertPendingEvents (ctx , tx , instanceID , []* history.Event {event }); err != nil {
279
279
return fmt .Errorf ("inserting signal event: %w" , err )
280
280
}
281
281
@@ -365,7 +365,7 @@ func (b *mysqlBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, err
365
365
WorkflowInstance : wfi ,
366
366
WorkflowInstanceState : core .WorkflowInstanceStateActive ,
367
367
Metadata : metadata ,
368
- NewEvents : []history.Event {},
368
+ NewEvents : []* history.Event {},
369
369
}
370
370
371
371
// Get new events
@@ -383,7 +383,7 @@ func (b *mysqlBackend) GetWorkflowTask(ctx context.Context) (*task.Workflow, err
383
383
var instanceID string
384
384
var attributes []byte
385
385
386
- historyEvent := history.Event {}
386
+ historyEvent := & history.Event {}
387
387
388
388
if err := events .Scan (
389
389
& historyEvent .ID ,
@@ -440,7 +440,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
440
440
task * task.Workflow ,
441
441
instance * workflow.Instance ,
442
442
state core.WorkflowInstanceState ,
443
- executedEvents , activityEvents , timerEvents []history.Event ,
443
+ executedEvents , activityEvents , timerEvents []* history.Event ,
444
444
workflowEvents []history.WorkflowEvent ,
445
445
) error {
446
446
tx , err := b .db .BeginTx (ctx , & sql.TxOptions {
@@ -537,7 +537,7 @@ func (b *mysqlBackend) CompleteWorkflowTask(
537
537
}
538
538
}
539
539
540
- historyEvents := []history.Event {}
540
+ historyEvents := []* history.Event {}
541
541
for _ , m := range events {
542
542
historyEvents = append (historyEvents , m .HistoryEvent )
543
543
}
@@ -611,7 +611,7 @@ func (b *mysqlBackend) GetActivityTask(ctx context.Context) (*task.Activity, err
611
611
var instanceID , executionID string
612
612
var attributes []byte
613
613
var metadataJson sql.NullString
614
- event := history.Event {}
614
+ event := & history.Event {}
615
615
616
616
if err := res .Scan (
617
617
& id , & event .ID , & instanceID , & executionID , & metadataJson , & event .Type ,
@@ -660,7 +660,7 @@ func (b *mysqlBackend) GetActivityTask(ctx context.Context) (*task.Activity, err
660
660
}
661
661
662
662
// CompleteActivityTask completes a activity task retrieved using GetActivityTask
663
- func (b * mysqlBackend ) CompleteActivityTask (ctx context.Context , instance * workflow.Instance , id string , event history.Event ) error {
663
+ func (b * mysqlBackend ) CompleteActivityTask (ctx context.Context , instance * workflow.Instance , id string , event * history.Event ) error {
664
664
tx , err := b .db .BeginTx (ctx , & sql.TxOptions {
665
665
Isolation : sql .LevelReadCommitted ,
666
666
})
@@ -691,7 +691,7 @@ func (b *mysqlBackend) CompleteActivityTask(ctx context.Context, instance *workf
691
691
}
692
692
693
693
// Insert new event generated during this workflow execution
694
- if err := insertPendingEvents (ctx , tx , instance .InstanceID , []history.Event {event }); err != nil {
694
+ if err := insertPendingEvents (ctx , tx , instance .InstanceID , []* history.Event {event }); err != nil {
695
695
return fmt .Errorf ("inserting new events for completed activity: %w" , err )
696
696
}
697
697
@@ -730,7 +730,7 @@ func (b *mysqlBackend) ExtendActivityTask(ctx context.Context, activityID string
730
730
return tx .Commit ()
731
731
}
732
732
733
- func scheduleActivity (ctx context.Context , tx * sql.Tx , instance * core.WorkflowInstance , event history.Event ) error {
733
+ func scheduleActivity (ctx context.Context , tx * sql.Tx , instance * core.WorkflowInstance , event * history.Event ) error {
734
734
a , err := history .SerializeAttributes (event .Attributes )
735
735
if err != nil {
736
736
return err
0 commit comments