-
Notifications
You must be signed in to change notification settings - Fork 45
/
main.go
38 lines (28 loc) · 794 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
package main
import (
"context"
"os"
"os/signal"
"github.com/cschleiden/go-workflows/backend"
"github.com/cschleiden/go-workflows/samples"
simple_split_worker "github.com/cschleiden/go-workflows/samples/simple-split-worker"
"github.com/cschleiden/go-workflows/worker"
)
func main() {
ctx := context.Background()
b := samples.GetBackend("simple-split")
// Run worker
go RunWorker(ctx, b)
c2 := make(chan os.Signal, 1)
signal.Notify(c2, os.Interrupt)
<-c2
}
func RunWorker(ctx context.Context, mb backend.Backend) {
w := worker.New(mb, nil)
w.RegisterWorkflow(simple_split_worker.Workflow1)
w.RegisterActivity(simple_split_worker.Activity1)
w.RegisterActivity(simple_split_worker.Activity2)
if err := w.Start(ctx); err != nil {
panic("could not start worker")
}
}