-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
53 lines (44 loc) · 1.25 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"github.com/vadiminshakov/committer/config"
"github.com/vadiminshakov/committer/core/cohort"
"github.com/vadiminshakov/committer/core/cohort/commitalgo"
"github.com/vadiminshakov/committer/core/cohort/commitalgo/hooks"
"github.com/vadiminshakov/committer/core/coordinator"
"github.com/vadiminshakov/committer/io/db"
"github.com/vadiminshakov/committer/io/gateway/grpc/server"
"github.com/vadiminshakov/gowal"
"os"
"os/signal"
"syscall"
)
func main() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
conf := config.Get()
database, err := db.New(conf.DBPath)
if err != nil {
panic(err)
}
mlog, err := gowal.NewWAL("wal", "msgs_")
if err != nil {
panic(err)
}
vlog, err := gowal.NewWAL("wal", "votes_")
if err != nil {
panic(err)
}
coordImpl, err := coordinator.New(conf, mlog, vlog, database)
if err != nil {
panic(err)
}
committer := commitalgo.NewCommitter(database, conf.CommitType, mlog, hooks.Propose, hooks.Commit, conf.Timeout)
cohortImpl := cohort.NewCohort(committer, cohort.Mode(conf.CommitType))
s, err := server.New(conf, cohortImpl, coordImpl, database)
if err != nil {
panic(err)
}
s.Run(server.WhiteListChecker)
<-ch
s.Stop()
}