-
Notifications
You must be signed in to change notification settings - Fork 202
/
parent_workflow.go
31 lines (25 loc) · 1.01 KB
/
parent_workflow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package child_workflow
import (
"go.temporal.io/sdk/workflow"
)
// @@@SNIPSTART samples-go-child-workflow-example-parent-workflow-definition
// SampleParentWorkflow is a Workflow Definition
// This Workflow Definition demonstrates how to start a Child Workflow Execution from a Parent Workflow Execution.
// Each Child Workflow Execution starts a new Run.
// The Parent Workflow Execution is notified only after the completion of last Run of the Child Workflow Execution.
func SampleParentWorkflow(ctx workflow.Context) (string, error) {
logger := workflow.GetLogger(ctx)
cwo := workflow.ChildWorkflowOptions{
WorkflowID: "ABC-SIMPLE-CHILD-WORKFLOW-ID",
}
ctx = workflow.WithChildOptions(ctx, cwo)
var result string
err := workflow.ExecuteChildWorkflow(ctx, SampleChildWorkflow, "World").Get(ctx, &result)
if err != nil {
logger.Error("Parent execution received child execution failure.", "Error", err)
return "", err
}
logger.Info("Parent execution completed.", "Result", result)
return result, nil
}
// @@@SNIPEND