@@ -44,7 +44,7 @@ func (d TinkDB) CreateWorkflow(ctx context.Context, wf Workflow, data string, id
44
44
if err != nil {
45
45
return errors .Wrap (err , "failed to create workflow" )
46
46
}
47
- err = insertInWorkflow (wf , tx )
47
+ err = insertInWorkflow (ctx , wf , tx )
48
48
if err != nil {
49
49
return errors .Wrap (err , "failed to create workflow" )
50
50
}
@@ -55,8 +55,8 @@ func (d TinkDB) CreateWorkflow(ctx context.Context, wf Workflow, data string, id
55
55
return nil
56
56
}
57
57
58
- func insertInWorkflow (wf Workflow , tx * sql.Tx ) error {
59
- _ , err := tx .Exec ( `
58
+ func insertInWorkflow (ctx context. Context , wf Workflow , tx * sql.Tx ) error {
59
+ _ , err := tx .ExecContext ( ctx , `
60
60
INSERT INTO
61
61
workflow (created_at, updated_at, template, devices, id)
62
62
VALUES
@@ -72,8 +72,8 @@ func insertInWorkflow(wf Workflow, tx *sql.Tx) error {
72
72
return nil
73
73
}
74
74
75
- func insertIntoWfWorkerTable (wfID uuid.UUID , workerID uuid.UUID , tx * sql.Tx ) error {
76
- _ , err := tx .Exec ( `
75
+ func insertIntoWfWorkerTable (ctx context. Context , wfID uuid.UUID , workerID uuid.UUID , tx * sql.Tx ) error {
76
+ _ , err := tx .ExecContext ( ctx , `
77
77
INSERT INTO
78
78
workflow_worker_map (workflow_id, worker_id)
79
79
VALUES
@@ -116,7 +116,7 @@ func insertActionList(ctx context.Context, db *sql.DB, yamlData string, id uuid.
116
116
return err
117
117
}
118
118
if uniqueWorkerID != workerUID {
119
- err = insertIntoWfWorkerTable (id , workerUID , tx )
119
+ err = insertIntoWfWorkerTable (ctx , id , workerUID , tx )
120
120
if err != nil {
121
121
return err
122
122
}
@@ -173,7 +173,7 @@ func insertActionList(ctx context.Context, db *sql.DB, yamlData string, id uuid.
173
173
return err
174
174
}
175
175
176
- _ , err = tx .Exec ( `
176
+ _ , err = tx .ExecContext ( ctx , `
177
177
INSERT INTO
178
178
workflow_state (workflow_id, current_worker, current_task_name, current_action_name, current_action_state, action_list, current_action_index, total_number_of_actions)
179
179
VALUES
@@ -203,7 +203,7 @@ func (d TinkDB) InsertIntoWfDataTable(ctx context.Context, req *pb.UpdateWorkflo
203
203
return errors .Wrap (err , "BEGIN transaction" )
204
204
}
205
205
206
- _ , err = tx .Exec ( `
206
+ _ , err = tx .ExecContext ( ctx , `
207
207
INSERT INTO
208
208
workflow_data (workflow_id, version, metadata, data)
209
209
VALUES
@@ -215,7 +215,7 @@ func (d TinkDB) InsertIntoWfDataTable(ctx context.Context, req *pb.UpdateWorkflo
215
215
216
216
if version > int32 (maxVersions ) {
217
217
cleanVersion := version - int32 (maxVersions )
218
- _ , err = tx .Exec ( `
218
+ _ , err = tx .ExecContext ( ctx , `
219
219
UPDATE workflow_data
220
220
SET
221
221
data = NULL
@@ -375,7 +375,7 @@ func (d TinkDB) DeleteWorkflow(ctx context.Context, id string, _ int32) error {
375
375
return errors .Wrap (err , "BEGIN transaction" )
376
376
}
377
377
378
- _ , err = tx .Exec ( `
378
+ _ , err = tx .ExecContext ( ctx , `
379
379
DELETE FROM workflow_worker_map
380
380
WHERE
381
381
workflow_id = $1;
@@ -384,7 +384,7 @@ func (d TinkDB) DeleteWorkflow(ctx context.Context, id string, _ int32) error {
384
384
return errors .Wrap (err , "Delete Workflow Error" )
385
385
}
386
386
387
- _ , err = tx .Exec ( `
387
+ _ , err = tx .ExecContext ( ctx , `
388
388
DELETE FROM workflow_state
389
389
WHERE
390
390
workflow_id = $1;
@@ -393,7 +393,7 @@ func (d TinkDB) DeleteWorkflow(ctx context.Context, id string, _ int32) error {
393
393
return errors .Wrap (err , "Delete Workflow Error" )
394
394
}
395
395
396
- res , err := tx .Exec ( `
396
+ res , err := tx .ExecContext ( ctx , `
397
397
UPDATE workflow
398
398
SET
399
399
deleted_at = NOW()
@@ -469,11 +469,11 @@ func (d TinkDB) UpdateWorkflow(ctx context.Context, wf Workflow, _ int32) error
469
469
470
470
switch {
471
471
case wf .Hardware == "" && wf .Template != "" :
472
- _ , err = tx .Exec ( `UPDATE workflow SET updated_at = NOW(), template = $2 WHERE id = $1;` , wf .ID , wf .Template )
472
+ _ , err = tx .ExecContext ( ctx , `UPDATE workflow SET updated_at = NOW(), template = $2 WHERE id = $1;` , wf .ID , wf .Template )
473
473
case wf .Hardware != "" && wf .Template == "" :
474
- _ , err = tx .Exec ( `UPDATE workflow SET updated_at = NOW(), devices = $2 WHERE id = $1;` , wf .ID , wf .Hardware )
474
+ _ , err = tx .ExecContext ( ctx , `UPDATE workflow SET updated_at = NOW(), devices = $2 WHERE id = $1;` , wf .ID , wf .Hardware )
475
475
default :
476
- _ , err = tx .Exec ( `UPDATE workflow SET updated_at = NOW(), template = $2, devices = $3 WHERE id = $1;` , wf .ID , wf .Template , wf .Hardware )
476
+ _ , err = tx .ExecContext ( ctx , `UPDATE workflow SET updated_at = NOW(), template = $2, devices = $3 WHERE id = $1;` , wf .ID , wf .Template , wf .Hardware )
477
477
}
478
478
479
479
if err != nil {
@@ -494,7 +494,7 @@ func (d TinkDB) UpdateWorkflowState(ctx context.Context, wfContext *pb.WorkflowC
494
494
return errors .Wrap (err , "BEGIN transaction" )
495
495
}
496
496
497
- _ , err = tx .Exec ( `
497
+ _ , err = tx .ExecContext ( ctx , `
498
498
UPDATE workflow_state
499
499
SET current_task_name = $2,
500
500
current_action_name = $3,
@@ -581,7 +581,7 @@ func (d TinkDB) InsertIntoWorkflowEventTable(ctx context.Context, wfEvent *pb.Wo
581
581
}
582
582
583
583
// TODO "created_at" field should be set in worker and come in the request
584
- _ , err = tx .Exec ( `
584
+ _ , err = tx .ExecContext ( ctx , `
585
585
INSERT INTO
586
586
workflow_event (workflow_id, worker_id, task_name, action_name, execution_time, message, status, created_at)
587
587
VALUES
0 commit comments