Hi,
I wanted to get some advice on what the best way to design my current workflow. I have a tree like workflow where each node is a child-workflow and that child node can have child-workflow. You can imagine that each node has information about the current node as well a list of children nodes.
{
name: string
children: Queue<Node>
}
The tricky part is that you don’t have a view of the whole tree and you only have the view of the top layer. As you process each node via activity, the activity will signal back what child nodes are left. These nodes will be added to the workflow via signal.
So right now, this can be done if I block until the child workflow is complete to process the next childworkflow. However, I wanted to know is there a way where I could process it all async.
Example:
CiCdWorkflow --> BuildWorkflow --> Job1 workflow
–> Job2 workflow
–> Job 3 workflow
Step 1) CiCdWorkflow starts the buildworkflow with a list of Jobs(Job1, Job2, Job3). The buildworkflow puts the jobs into a queue and does a loop until queue job is empty.
Step 2) let’s say Job1 executes. It completes via signal to the job workflow. The signal will also contain a list of childnodes to process next. The job1 workflow will complete and then return with a list of children node. BuildWorkflow will add it to the queue of jobs.
Because in step 2, I depend on the return on the children nodes from the job workflow, it’s not clear to me how you would achieve this with a promise since there seems to be only two options:
- Promise.all which waits for all the jobs at the level to be complete before starting children. Since each job can finish at different rates I want each node to start the children nodes when it’s complete.
- Promise.anyOf this won’t work because I need the return of the child nodes from the job workflow.
Any suggestion appreciated.
Thanks!