Skip to content

Commit 508722d

Browse files
committed
update cancelation sample
Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent 9fee2bc commit 508722d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cancellation/activity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (a *Activities) ActivityToBeCanceled(ctx context.Context) (string, error) {
2121
activity.RecordHeartbeat(ctx, "")
2222
case <-ctx.Done():
2323
logger.Info("context is cancelled")
24-
return "I am canceled by Done", nil
24+
return "I am canceled by Done", ctx.Err()
2525
}
2626
}
2727
}

cancellation/workflow.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ func YourWorkflow(ctx workflow.Context) error {
3131
if err != nil {
3232
logger.Error("CleanupActivity failed", "Error", err)
3333
}
34+
3435
}()
3536

3637
var result string
3738
err := workflow.ExecuteActivity(ctx, a.ActivityToBeCanceled).Get(ctx, &result)
39+
if err != nil {
40+
return err
41+
}
3842
logger.Info(fmt.Sprintf("ActivityToBeCanceled returns %v, %v", result, err))
3943

4044
err = workflow.ExecuteActivity(ctx, a.ActivityToBeSkipped).Get(ctx, nil)

0 commit comments

Comments
 (0)