forked from temporalio/samples-go
/
main.go
36 lines (28 loc) · 823 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
package main
import (
"context"
"log"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/worker"
"github.com/temporalio/samples-go/searchattributes"
)
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()
ctx := context.WithValue(context.Background(), searchattributes.ClientCtxKey, c)
w := worker.New(c, "search-attributes", worker.Options{
BackgroundActivityContext: ctx,
})
w.RegisterWorkflow(searchattributes.SearchAttributesWorkflow)
w.RegisterActivity(searchattributes.ListExecutions)
err = w.Run(worker.InterruptCh())
if err != nil {
log.Fatalln("Unable to start worker", err)
}
}