temporal
temporal copied to clipboard
Add ability to transfer child workflows to new parent run when parent calls continue as new
Request: Add ability to transfer child workflows to new parent run when parent calls continue as new.
Currently the child workflow is not transferred and follows the parentClosePolicy.
@tsurdilo Can you clarify what "transfer child workflows" would mean in practice?
Today, upon continue as new, do child workflows continue to follow the parentClosePolicy or are they effectively abandoned?
Today, it seems that with the default PARENT_CLOSE_POLICY_TERMINATE
, children are terminated if the parent workflow continues as new. Until there is a built-in way to handle transfer of children to the next WF run, I'm doing the following:
- Save an array/map
pendingChildren
of all running children in the parent worklfow - Pass workflowIds to the next run, as an argument of the continueAsNew fn
- Call an activity for each workflow that waits for their result and clears items from
pendingChildren
on error or success
Unfortunately, workflows (at least in TS SDK) don't allow to wait for workflows that they didn't directly spawn. We can use getExternalWorkflowHandle, but it doesn't really expose much info/functionalyity (like wait for result or the status). Thus, we need to use activities.
(if there is better strategies @tsurdilo, would love some feedback)
Is #373 related(a valid preparation) to this issue?