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_ABANDON
PARENT_CLOSE_POLICY_TERMINATE
PARENT_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_ABANDON
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
}