Skip to main content

How to set ChildWorkflowOptions in Go

Used to set all child Workflow specific options

NamespaceSet the namespace of the Child Workflow Executionstring
WorkflowIDSet the Id of the Child Workflow to be scheduledstring
TaskQueueSet Task Queue that the child Workflow needs to be scheduled onstring
WorkflowExecutionTimeoutSet the end to end timeout for the child Workflow execution including retriestime.Duration
WorkflowRunTimeoutSet the timeout for a single run of the child Workflow executiontime.Duration
WorkflowTaskTimeoutSet the maximum execution time of a single Workflow Tasktime.Duration
WaitForCancellationSet to wait for canceled child Workflow to be endedbool
WorkflowIDReusePolicySet if server allow reuse of Workflow IdWorkflowIdReusePolicy
RetryPolicySet how to retry child Workflow if error happensRetryPolicy
CronScheduleSet the cron schedule for child Workflowstring
MemoSet non-indexed info that will be shown in list child Workflowmap[string]interface{}
SearchAttributesSet indexed info that can be used in query of List/Scan/Count child Workflow APIsmap[string]interface{}
ParentClosePolicySet policy to decide what to do for the child when the parent closesParentClosePolicy

Parent Close Policy

In Go, a Parent Close Policy is set on the ParentClosePolicy field of an instance of workflow.ChildWorkflowOptions. The possible values can be obtained from the package.


The Child Workflow Options are then applied to the instance of workflow.Context by using the WithChildOptions API, which is then passed to the ExecuteChildWorkflow() call.

import (
// ...

func YourWorkflowDefinition(ctx workflow.Context, params ParentParams) (ParentResp, error) {
// ...
childWorkflowOptions := workflow.ChildWorkflowOptions{
// ...
ctx = workflow.WithChildOptions(ctx, childWorkflowOptions)
childWorkflowFuture := workflow.ExecuteChildWorkflow(ctx, YourOtherWorkflowDefinition, ChildParams{})
// ...

func YourOtherWorkflowDefinition(ctx workflow.Context, params ChildParams) (ChildResp, error) {
// ...
return resp, nil