forked from temporalio/samples-go
/
main.go
34 lines (29 loc) · 897 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
package main
import (
"context"
"github.com/temporalio/samples-go/updatabletimer"
"log"
"time"
"go.temporal.io/sdk/client"
)
// Starts updatable timer workflow with initial wake-up time in 30 seconds.
func main() {
c, err := client.Dial(client.Options{
HostPort: client.DefaultHostPort,
})
if err != nil {
log.Fatalln("Unable to create client", err)
}
defer c.Close()
workflowOptions := client.StartWorkflowOptions{
ID: updatabletimer.WorkflowID,
TaskQueue: updatabletimer.TaskQueue,
}
wakeUpTime := time.Now().Add(30 * time.Second)
we, err := c.ExecuteWorkflow(context.Background(), workflowOptions, updatabletimer.Workflow, wakeUpTime)
if err != nil {
log.Fatalln("Unable to start workflow", err)
}
log.Println("Started workflow that is going to block on an updatable timer",
"WorkflowID", we.GetID(), "RunID", we.GetRunID(), "WakeUpTime", wakeUpTime)
}