dapr / js-sdk

Dapr SDK for Javascript
Apache License 2.0
192 stars 80 forks source link

Example using child workflows #568

Closed sce9sc closed 1 month ago

sce9sc commented 6 months ago

Since, according to the documentation, having a workflow that spawns many workers is not ideal and the proposed solution is to have child workflows can you please point me to the right direction on how to implement a workflow that schedules other workworkflows as child workflows.

Also according to the documentation

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.

How do you accomplish the above ?

Thanks, Great work.

shubham1172 commented 6 months ago

Hi @sce9sc, you can see callSubWorkflow here to call a child-workflow. https://github.com/dapr/js-sdk/blob/5c2b40ac94b50f6a5bdb32008f6a47da69946d95/src/workflow/runtime/WorkflowContext.ts#L107

Please see https://github.com/dapr/python-sdk/blob/main/examples/demo_workflow/app.py#L59 for an example in Python SDK.

We need to add an example in this SDK as well. Please feel free to drop a PR if you are willing to contribute 🙂

sce9sc commented 6 months ago

Thanks I will try to create an example . I've seen that there is a test that I can use also .

I saw that child workflows needs to be registrered together with the parent workflows. And the parrent workflow can then call that workflow. What if I wanted that child workflow to be written in another language ? How can this be accomplished. The reason behind this is that I might want to create an orchestration workflow in one language and the child workflows in another.

Sincerely thank you for your prompt replies.

dapr-bot commented 4 months ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

shubham1172 commented 4 months ago

/keep-alive

dapr-bot commented 2 months ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot commented 1 month ago

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.