From 647f9acf07e6efc875ea82042a45f86650869295 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Thu, 25 Jan 2024 15:10:44 +0530 Subject: [PATCH 1/3] Adding recursive terminate/purge in workflow api Signed-off-by: Shivam Kumar --- .../content/en/reference/api/workflow_api.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/reference/api/workflow_api.md b/daprdocs/content/en/reference/api/workflow_api.md index 9f9c34de81a..a660afbaf90 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 will terminate all of the child workflows created by the workflow instance. This can be disabled by setting the query parameter `non_recursive` to `true`. + + Terminating a workflow will have 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 will purge all of the child workflows created by the workflow instance. This can be disabled 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 From b3d49db4c562a1ee55261867f8f73272f65a7210 Mon Sep 17 00:00:00 2001 From: Shivam Kumar Date: Fri, 26 Jan 2024 10:48:52 +0530 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Signed-off-by: Shivam Kumar --- daprdocs/content/en/reference/api/workflow_api.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daprdocs/content/en/reference/api/workflow_api.md b/daprdocs/content/en/reference/api/workflow_api.md index a660afbaf90..1dc80ef5413 100644 --- a/daprdocs/content/en/reference/api/workflow_api.md +++ b/daprdocs/content/en/reference/api/workflow_api.md @@ -61,9 +61,9 @@ POST http://localhost:3500/v1.0-beta1/workflows/// Date: Thu, 1 Feb 2024 13:55:49 +0530 Subject: [PATCH 3/3] review comments Signed-off-by: Shivam Kumar --- .../building-blocks/workflow/workflow-features-concepts.md | 4 +--- .../building-blocks/workflow/workflow-overview.md | 2 +- 2 files changed, 2 insertions(+), 4 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 ce39d4bac96..564cacd3b99 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 f5b6dae8b6d..089ff931afa 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" >}})