Cancelling a CronSchedule workflow after allowing it to finish

529 Views Asked by At

If I have a workflow with Cronschedule specified with multiple activities, is there a way to cancel/terminate it only after all activities in the workflow have been executed. I also don't want it to have the ContinueAsNew status anymore.

1

There are 1 best solutions below

4
On

Best way is to cancel self as the last step in the workflow. You can either use an activity to call the Cadence API:

CancelWorkflow(ctx context.Context, workflowID string, runID string) error

or use RequestCancel feature.

func RequestCancelExternalWorkflow(ctx Context, workflowID, runID string) Future {

It's called external but if you put self workflowID, it should also work.