-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (34 loc) · 903 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
39
40
41
42
43
44
45
package main
import (
"context"
"github.com/VarthanV/pub-sub/broker"
"github.com/VarthanV/pub-sub/pkg/config"
"github.com/VarthanV/pub-sub/pkg/database"
"github.com/VarthanV/pub-sub/server"
"github.com/sirupsen/logrus"
)
func main() {
cfg, err := config.Load()
if err != nil {
logrus.Fatal("unable to load config ", err)
}
db, err := database.Init(cfg.Database.Name,
cfg.Database.DoMigrations)
if err != nil {
logrus.Fatal("error in initializing db ", err)
}
// Init broker
b := broker.New(db, cfg)
controller := server.NewController(db, b)
logrus.Info("Starting broker.....")
err = b.Start(context.Background())
if err != nil {
logrus.Fatal("error in starting broker ", err)
}
logrus.Info(`
_ _ __ _
|_) | | |_) __ (_ | | |_)
| |_| |_) __) |_| |_)
`)
server.InitServer(cfg.Server.HTTPPort, controller)
}