forked from temporalio/samples-go
/
main.go
46 lines (37 loc) · 900 Bytes
/
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
package main
import (
"context"
// "fmt"
"log"
"github.com/pborman/uuid"
"github.com/temporalio/samples-go/temporal-fixtures/openNclosed"
"strconv"
"go.temporal.io/sdk/client"
)
var (
NumberOfWorkflows = 5
KeepOpen = true
)
func main() {
// The client is a heavyweight object that should be created once per process.
c, err := client.Dial(client.Options{Namespace: "default"})
if err != nil {
log.Fatalln("Unable to create client", err)
}
defer c.Close()
uuidvar := uuid.New()
i := 1
for i <= NumberOfWorkflows {
id := uuidvar[:8] + "###___" + strconv.Itoa(i)
i++
workflowOptions := client.StartWorkflowOptions{
ID: id,
TaskQueue: "open-n-closed",
}
_, err := c.ExecuteWorkflow(context.Background(), workflowOptions,
openNclosed.OpenNClosedWorkflow, KeepOpen)
if err != nil {
log.Fatalln("Unable to execute workflow", err)
}
}
}