How to set ChildWorkflowOptions in Go
Used to set all Child Workflow specific options
| Field | Description | Type |
|---|---|---|
| Namespace | Set the namespace of the Child Workflow Execution | string |
| WorkflowID | Set the Id of the Child Workflow to be scheduled | string |
| TaskQueue | Set Task Queue that the Child Workflow needs to be scheduled on | string |
| WorkflowExecutionTimeout | Set the end to end timeout for the Child Workflow Execution including retries | time.Duration |
| WorkflowRunTimeout | Set the timeout for a single run of the Child Workflow Execution | time.Duration |
| WorkflowTaskTimeout | Set the maximum execution time of a single Workflow Task | time.Duration |
| WaitForCancellation | Set to wait for canceled Child Workflow to be ended | bool |
| WorkflowIDReusePolicy | Set if server allow reuse of Workflow Id | WorkflowIdReusePolicy |
| RetryPolicy | Set how to retry Child Workflow if error happens | RetryPolicy |
| CronSchedule | Set the cron schedule for Child Workflow | string |
| Memo | Set non-indexed info that will be shown in list Child Workflow | map[string]interface{} |
| SearchAttributes | Set indexed info that can be used in query of List/Scan/Count Child Workflow APIs | map[string]interface{} |
| ParentClosePolicy | Set policy to decide what to do for the child when the parent closes | ParentClosePolicy |
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 go.temporal.io/api/enums/v1 package.
PARENT_CLOSE_POLICY_ABANDONPARENT_CLOSE_POLICY_TERMINATEPARENT_CLOSE_POLICY_REQUEST_CANCEL
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.
- Type:
ParentClosePolicy - Default:
PARENT_CLOSE_POLICY_TERMINATE
import (
// ...
"go.temporal.io/api/enums/v1"
)
func YourWorkflowDefinition(ctx workflow.Context, params ParentParams) (ParentResp, error) {
// ...
childWorkflowOptions := workflow.ChildWorkflowOptions{
// ...
ParentClosePolicy: enums.PARENT_CLOSE_POLICY_ABANDON,
}
ctx = workflow.WithChildOptions(ctx, childWorkflowOptions)
childWorkflowFuture := workflow.ExecuteChildWorkflow(ctx, YourOtherWorkflowDefinition, ChildParams{})
// ...
}
func YourOtherWorkflowDefinition(ctx workflow.Context, params ChildParams) (ChildResp, error) {
// ...
return resp, nil
}