forked from temporalio/samples-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (28 loc) · 820 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
package main
import (
"context"
"log"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/worker"
"github.com/temporalio/samples-go/mutex"
)
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, "mutex", worker.Options{
BackgroundActivityContext: context.WithValue(context.Background(), mutex.ClientContextKey, c),
})
w.RegisterActivity(mutex.SignalWithStartMutexWorkflowActivity)
w.RegisterWorkflow(mutex.MutexWorkflow)
w.RegisterWorkflow(mutex.SampleWorkflowWithMutex)
err = w.Run(worker.InterruptCh())
if err != nil {
log.Fatalln("Unable to start worker", err)
}
}