-
Notifications
You must be signed in to change notification settings - Fork 202
/
workflow.go
42 lines (35 loc) · 1006 Bytes
/
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
32
33
34
35
36
37
38
39
40
41
42
package dynamic
import (
"time"
"go.temporal.io/sdk/workflow"
)
// SampleGreetingsWorkflow Workflow.
func SampleGreetingsWorkflow(ctx workflow.Context) error {
ao := workflow.ActivityOptions{
StartToCloseTimeout: 10 * time.Second,
}
ctx = workflow.WithActivityOptions(ctx, ao)
logger := workflow.GetLogger(ctx)
var greetResult string
err := workflow.ExecuteActivity(ctx, "GetGreeting").Get(ctx, &greetResult)
if err != nil {
logger.Error("Get greeting failed.", "Error", err)
return err
}
// Get Name.
var nameResult string
err = workflow.ExecuteActivity(ctx, "GetName").Get(ctx, &nameResult)
if err != nil {
logger.Error("Get name failed.", "Error", err)
return err
}
// Say Greeting.
var sayResult string
err = workflow.ExecuteActivity(ctx, "SayGreeting", greetResult, nameResult).Get(ctx, &sayResult)
if err != nil {
logger.Error("Marshalling failed with error.", "Error", err)
return err
}
logger.Info("Workflow completed.", "Result", sayResult)
return nil
}