From 7dea32b7c8e96402698146c556b8e05173fd2123 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Fri, 2 Feb 2024 01:56:53 +0530 Subject: [PATCH] Adding recursive terminate/purge in workflow API (#3969) * Adding recursive terminate/purge in workflow api Signed-off-by: Shivam Kumar * Apply suggestions from code review Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: Shivam Kumar * review comments Signed-off-by: Shivam Kumar --------- Signed-off-by: Shivam Kumar Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> --- .../workflow/workflow-features-concepts.md | 4 +--- .../workflow/workflow-overview.md | 2 +- .../content/en/reference/api/workflow_api.md | 18 ++++++++++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md index 17aec6553..4d4a30954 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-features-concepts.md @@ -97,9 +97,7 @@ Child workflows have many benefits: The return value of a child workflow is its output. If a child workflow fails with an exception, then that exception is surfaced to the parent workflow, just like it is when an activity task fails with an exception. Child workflows also support automatic retry policies. -{{% alert title="Note" color="primary" %}} -Because child workflows are independent of their parents, terminating a parent workflow does not affect any child workflows. You must terminate each child workflow independently using its instance ID. -{{% /alert %}} +Terminating a parent workflow terminates all of the child workflows created by the workflow instance. You can disable this by setting the query parameter `non_recursive` to `true` while sending the terminate request to the parent workflow. See [the terminate workflow api]({{< ref "workflow_api.md#terminate-workflow-request" >}}) for more information. ## Durable timers diff --git a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md index f5b6dae8b..089ff931a 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/workflow/workflow-overview.md @@ -41,7 +41,7 @@ With Dapr Workflow, you can write activities and then orchestrate those activiti ### Child workflows -In addition to activities, you can write workflows to schedule other workflows as child workflows. A child workflow is independent of the parent workflow that started it and support automatic retry policies. +In addition to activities, you can write workflows to schedule other workflows as child workflows. A child workflow has its own instance ID, history, and status that is independent of the parent workflow that started it, except for the fact that terminating the parent workflow terminates all of the child workflows created by it. Child workflow also supports automatic retry policies. [Learn more about child workflows.]({{< ref "workflow-features-concepts.md#child-workflows" >}}) diff --git a/daprdocs/content/en/reference/api/workflow_api.md b/daprdocs/content/en/reference/api/workflow_api.md index 9f9c34de8..1dc80ef54 100644 --- a/daprdocs/content/en/reference/api/workflow_api.md +++ b/daprdocs/content/en/reference/api/workflow_api.md @@ -57,15 +57,23 @@ The API call will provide a response similar to this: Terminate a running workflow instance with the given name and instance ID. ``` -POST http://localhost:3500/v1.0-beta1/workflows///terminate +POST http://localhost:3500/v1.0-beta1/workflows///terminate[?non_recursive=false] ``` +{{% alert title="Note" color="primary" %}} + Terminating a workflow terminates all of the child workflows created by the workflow instance. You can disable this by setting the query parameter `non_recursive` to `true`. + +Terminating a workflow has no effect on any in-flight activity executions that were started by the terminated instance. + +{{% /alert %}} + ### URL parameters Parameter | Description --------- | ----------- `workflowComponentName` | Use `dapr` for Dapr Workflows `instanceId` | Unique value created for each run of a specific workflow +`non_recursive` | (Optional) Boolean to determine if Dapr should not recursively terminate child workflows created by the workflow instance. Default value is `false`. ### HTTP response codes @@ -171,15 +179,21 @@ None. Purge the workflow state from your state store with the workflow's instance ID. ``` -POST http://localhost:3500/v1.0-beta1/workflows///purge +POST http://localhost:3500/v1.0-beta1/workflows///purge[?non_recursive=false] ``` +{{% alert title="Note" color="primary" %}} + Purging a workflow purges all of the child workflows created by the workflow instance. You can disable this by setting the query parameter `non_recursive` to `true`. + +{{% /alert %}} + ### URL parameters Parameter | Description --------- | ----------- `workflowComponentName` | Use `dapr` for Dapr Workflows `instanceId` | Unique value created for each run of a specific workflow +`non_recursive` | (Optional) Boolean to determine if Dapr should not recursively purge child workflows created by the workflow instance. Default value is `false`. ### HTTP response codes