@@ -7,6 +7,7 @@ description: "Decomposes complex Workflows into smaller, reusable units. Each ch
77
88import Tabs from ' @theme/Tabs' ;
99import TabItem from ' @theme/TabItem' ;
10+ import { AnnotatedCode } from ' @site/src/components' ;
1011
1112## Overview
1213
@@ -167,13 +168,33 @@ In Go, `workflow.ExecuteChildWorkflow()` returns a `ChildWorkflowFuture`, and ca
167168### Asynchronous Child Workflow
168169
169170The following example starts a Child Workflow asynchronously with an ABANDON policy.
170- The parent receives the child's execution info without waiting for completion:
171+ The parent receives the child's execution info without waiting for completion. Select a concept to highlight the matching lines :
171172
172173<Tabs groupId = " language" queryString >
173174<TabItem value = " python" label = " Python" >
174-
175+ <AnnotatedCode
176+ annotations = { [
177+ {
178+ label: ' Parent Close Policy' ,
179+ description:
180+ ' Controls what happens to the Child Workflow when the parent closes. ABANDON lets the child keep running after the parent completes.' ,
181+ lines: [14 ],
182+ },
183+ {
184+ label: ' Workflow Id' ,
185+ description:
186+ ' Gives the Child Workflow a stable identity for tracking, querying, and deduplication in the UI.' ,
187+ lines: [13 ],
188+ },
189+ {
190+ label: ' Async start' ,
191+ description:
192+ ' Starts the Child Workflow without waiting for it to finish. The parent continues after the child has started.' ,
193+ lines: [10 , 11 , 12 , 13 , 14 , 15 ],
194+ },
195+ ]}
196+ >
175197``` python
176- # workflows.py
177198from temporalio import workflow
178199from temporalio.workflow import ParentClosePolicy
179200
@@ -183,28 +204,41 @@ from child_workflows import ChildWorkflow
183204class ParentWorkflow :
184205 @workflow.run
185206 async def run (self , input : str ) -> str :
186- # Async call - returns handle once child starts
187207 handle = await workflow.start_child_workflow(
188208 ChildWorkflow.run,
189209 input ,
190210 id = f " child- { workflow.uuid4()} " ,
191211 parent_close_policy = ParentClosePolicy.ABANDON ,
192212 )
193213
194- # Parent continues without waiting for child completion
195214 return handle.id
196215```
197-
216+ </ AnnotatedCode >
198217</TabItem >
199218<TabItem value = " go" label = " Go" >
200-
219+ <AnnotatedCode
220+ annotations = { [
221+ {
222+ label: ' Parent Close Policy' ,
223+ description:
224+ ' Controls what happens to the Child Workflow when the parent closes. ABANDON lets the child keep running after the parent completes.' ,
225+ lines: [3 ],
226+ },
227+ {
228+ label: ' Workflow Id' ,
229+ description:
230+ ' Gives the Child Workflow a stable identity for tracking, querying, and deduplication in the UI.' ,
231+ lines: [14 ],
232+ },
233+ {
234+ label: ' Async start' ,
235+ description:
236+ ' Starts the Child Workflow without waiting for it to finish. The parent continues after the child has started.' ,
237+ lines: [7 ],
238+ },
239+ ]}
240+ >
201241``` go
202- // parent_workflow.go
203- import (
204- enumspb " go.temporal.io/api/enums/v1"
205- " go.temporal.io/sdk/workflow"
206- )
207-
208242func ParentWorkflow (ctx workflow .Context , input string ) (string , error ) {
209243 cwo := workflow.ChildWorkflowOptions {
210244 ParentClosePolicy: enumspb.PARENT_CLOSE_POLICY_ABANDON ,
@@ -213,22 +247,40 @@ func ParentWorkflow(ctx workflow.Context, input string) (string, error) {
213247
214248 childFuture := workflow.ExecuteChildWorkflow (ctx, ChildWorkflow, input)
215249
216- // Wait for child to start, not complete
217250 var childWE workflow.Execution
218251 if err := childFuture.GetChildWorkflowExecution ().Get (ctx, &childWE); err != nil {
219252 return " " , err
220253 }
221254
222- // Parent continues without waiting for child completion
223255 return childWE.ID , nil
224256}
225257```
226-
258+ </ AnnotatedCode >
227259</TabItem >
228260<TabItem value = " java" label = " Java" >
229-
261+ <AnnotatedCode
262+ annotations = { [
263+ {
264+ label: ' Parent Close Policy' ,
265+ description:
266+ ' Controls what happens to the Child Workflow when the parent closes. ABANDON lets the child keep running after the parent completes.' ,
267+ lines: [6 ],
268+ },
269+ {
270+ label: ' Workflow Id' ,
271+ description:
272+ ' Gives the Child Workflow a stable identity for tracking, querying, and deduplication in the UI.' ,
273+ lines: [5 ],
274+ },
275+ {
276+ label: ' Async start' ,
277+ description:
278+ ' Starts the Child Workflow without waiting for it to finish. The parent continues after the child has started.' ,
279+ lines: [11 ],
280+ },
281+ ]}
282+ >
230283``` java
231- // ParentWorkflowImpl.java
232284public class ParentWorkflowImpl implements ParentWorkflow {
233285 @Override
234286 public WorkflowExecution execute (String input ) {
@@ -239,21 +291,39 @@ public class ParentWorkflowImpl implements ParentWorkflow {
239291
240292 ChildWorkflow child = Workflow . newChildWorkflowStub(ChildWorkflow . class, options);
241293
242- // Async call - returns immediately
243294 Async . function(child:: processData, input);
244295
245- // Get child execution info without waiting for completion
246296 Promise<WorkflowExecution > childExecution = Workflow . getWorkflowExecution(child);
247- return childExecution. get(); // Blocks only until child starts
297+ return childExecution. get();
248298 }
249299}
250300```
251-
301+ </ AnnotatedCode >
252302</TabItem >
253303<TabItem value = " typescript" label = " TypeScript" >
254-
304+ <AnnotatedCode
305+ annotations = { [
306+ {
307+ label: ' Parent Close Policy' ,
308+ description:
309+ ' Controls what happens to the Child Workflow when the parent closes. ABANDON lets the child keep running after the parent completes.' ,
310+ lines: [7 ],
311+ },
312+ {
313+ label: ' Workflow Id' ,
314+ description:
315+ ' Gives the Child Workflow a stable identity for tracking, querying, and deduplication in the UI.' ,
316+ lines: [10 ],
317+ },
318+ {
319+ label: ' Async start' ,
320+ description:
321+ ' Starts the Child Workflow without waiting for it to finish. The parent continues after the child has started.' ,
322+ lines: [5 , 6 , 7 , 8 ],
323+ },
324+ ]}
325+ >
255326``` typescript
256- // workflows.ts
257327import { startChild , ParentClosePolicy } from ' @temporalio/workflow' ;
258328import { childWorkflow } from ' ./child-workflows' ;
259329
@@ -263,12 +333,10 @@ export async function parentWorkflow(input: string): Promise<string> {
263333 parentClosePolicy: ParentClosePolicy .PARENT_CLOSE_POLICY_ABANDON ,
264334 });
265335
266- // Parent continues without waiting for child completion
267- // childHandle.workflowId and childHandle.firstExecutionRunId are available
268336 return childHandle .workflowId ;
269337}
270338```
271-
339+ </ AnnotatedCode >
272340</TabItem >
273341</Tabs >
274342
0 commit comments