Difference between Cancel and Terminate

What’s the difference between PARENT_CLOSE_POLICY_REQUEST_CANCEL and PARENT_CLOSE_POLICY_TERMINATE? How can I handle a cancellation in my workflow? I need it to get to the end when it’s past a certain point.

Thanks!

Terminate is like kill -9. It stops workflow without giving it any chance to execute any cleanup logic.

Cancellation allows the workflow to execute whatever cleanup logic necessary (even long-running) before completing it.

The cancellation mechanism depends on the SDK. In Go, it just invalidates context passed to a workflow function.

In Java, it cancels CancellationScope that wraps the main workflow function.