-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (33 loc) · 745 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
package main
import (
"log"
"github.com/austinov/rocker-bot/bot"
"github.com/austinov/rocker-bot/config"
"github.com/austinov/rocker-bot/loader/cmetal"
"github.com/austinov/rocker-bot/store"
"github.com/austinov/rocker-bot/store/pg"
)
func main() {
cfg := config.GetConfig()
if err := cfg.Verify(); err != nil {
log.Fatal(err)
}
dao := createDao(cfg.DB)
defer dao.Close()
l := cmetal.New(cfg.CMetal, dao)
// start loader in separate go-routine
//go l.Start()
b := bot.New(cfg.Bot, dao)
// start bot and block until return
b.Start()
// stop loader
l.Stop()
}
func createDao(cfg config.DBConfig) store.Dao {
switch cfg.Type {
case "pg":
return pg.New(cfg)
}
log.Fatal("Unknown db type " + cfg.Type)
return nil
}