forked from temporalio/samples-go
/
main.go
49 lines (40 loc) · 1.18 KB
/
main.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
43
44
45
46
47
48
49
package main
import (
"context"
"flag"
"io/ioutil"
"log"
"github.com/pborman/uuid"
"go.temporal.io/sdk/client"
"gopkg.in/yaml.v3"
"github.com/temporalio/samples-go/dsl"
)
func main() {
var dslConfig string
flag.StringVar(&dslConfig, "dslConfig", "dsl/workflow1.yaml", "dslConfig specify the yaml file for the dsl workflow.")
flag.Parse()
data, err := ioutil.ReadFile(dslConfig)
if err != nil {
log.Fatalln("failed to load dsl config file", err)
}
var dslWorkflow dsl.Workflow
if err := yaml.Unmarshal(data, &dslWorkflow); err != nil {
log.Fatalln("failed to unmarshal dsl config", err)
}
// The client is a heavyweight object that should be created once per process.
c, err := client.Dial(client.Options{
HostPort: client.DefaultHostPort,
})
if err != nil {
log.Fatalln("Unable to create client", err)
}
workflowOptions := client.StartWorkflowOptions{
ID: "dsl_" + uuid.New(),
TaskQueue: "dsl",
}
we, err := c.ExecuteWorkflow(context.Background(), workflowOptions, dsl.SimpleDSLWorkflow, dslWorkflow)
if err != nil {
log.Fatalln("Unable to execute workflow", err)
}
log.Println("Started workflow", "WorkflowID", we.GetID(), "RunID", we.GetRunID())
}