I have a workflow, which base on an incoming signal would need to stop any currently running activity (i.e a cancel event, need to stop whatever we are doing and go to cleanup)
First, I create an activityCtx with cancel function
activityCtx, cancelActivity := workflow.WithCancel(ctx)
Then launch my activity using that activityCtx.
And, when I get that signal, i invoke cancelActivity().
I can see the activity is cancel in workflow, as I get CanceledError when trying to get status of the ExecuteActivity:
activityErr = workflow.ExecuteActivity(activityCtx, SomeActivity, payload).Get(activityCtx, nil)
- this returns canceledError
Questions:
- In SomeActivity, I am doing select on ctx.Done(). But the signal never came and hence my activity keeps running. I am sending heartbeat inside my activity: activity.RecordHeartBeat(ctx, 100) - where ctx is passed into the activity method (as first argument). Am my expectation correct? (i.e I should get ctx.Done inside activity when cancelFunc is called?)
- In go sdk docs, there is this statement: Cancellation is only delivered to Activities that call
RecordActivityHeartbeat
- Is it really that specific function? or just activity.RecordHeartBeat is ok?
Also is attached my options used to start activity
options := workflow.ActivityOptions{
StartToCloseTimeout: time.Hour,
HeartbeatTimeout: time.Minute,
// Optionally provide a customized RetryPolicy.
// Temporal retries failures by default, this is just an example.
RetryPolicy: &temporal.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 1.6,
MaximumInterval: 5 * time.Minute,
MaximumAttempts: 1,
},
}