-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (28 loc) · 923 Bytes
/
main.go
File metadata and controls
36 lines (28 loc) · 923 Bytes
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
package main
import (
requestcancelexternalworkflow "github.com/temporalio/samples-go/request-cancel-external-workflow"
"log"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/worker"
"github.com/temporalio/samples-go/cancellation"
)
// @@@SNIPSTART samples-go-cancellation-worker-starter
func main() {
// The client and worker are heavyweight objects 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)
}
defer c.Close()
w := worker.New(c, "cancel-activity", worker.Options{})
w.RegisterWorkflow(requestcancelexternalworkflow.CancellingWorkflow)
w.RegisterWorkflow(requestcancelexternalworkflow.ChildWorkflow)
w.RegisterActivity(&cancellation.Activities{})
err = w.Run(worker.InterruptCh())
if err != nil {
log.Fatalln("Unable to start worker", err)
}
}
// @@@SNIPEND