-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
29 lines (24 loc) · 798 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
package main
import (
"context"
"github.com/mehmetolgundev/distributed-watcher/domain/usecase"
"github.com/mehmetolgundev/distributed-watcher/infra/db"
"github.com/mehmetolgundev/distributed-watcher/infra/zookeeper"
"github.com/mehmetolgundev/distributed-watcher/repository"
"sync"
)
func main() {
ctx := context.Background()
mongoClient := db.NewClient(ctx)
zookeeperClient := zookeeper.NewClient()
taskDBRepository := repository.NewTaskDBRepository(mongoClient)
taskZKRepository := repository.NewTaskZKRepository(zookeeperClient)
taskService := usecase.NewTaskService(taskDBRepository, taskZKRepository)
taskService.Register(ctx)
wg := &sync.WaitGroup{}
wg.Add(3)
go taskService.WatchLeader(wg)
go taskService.WatchNodes(ctx, wg)
go taskService.Start(ctx, wg)
wg.Wait()
}