Child Workflows
Child workflows can be spawned from an existing ctx
object:
childWorkflow, err := ctx.SpawnWorkflow("child-workflow", childInput, &worker.SpawnWorkflowOpts{})
if err != nil {
return nil, err
}
The SpawnWorkflow
method returns a ChildWorkflow
object that can be used to wait for the completion of the child workflow:
childResult, err := childWorkflow.Result()
if err != nil {
return nil, err
}
Spawning ChildWorkflows in Bulk
Child workflows can also be spawned in bulk:
_, err = ctx.SpawnWorkflows(
[]*worker.SpawnWorkflowsOpts{
{
WorkflowName: "step-one",
Sticky: &sticky,
},
{
WorkflowName: "step-one",
Sticky: &sticky,
},
})