-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
50 lines (39 loc) · 1.01 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
package main
import (
"flag"
"github.com/uesteibar/scribano/asyncapi/repos/messagesrepo"
"github.com/uesteibar/scribano/storage/db"
"github.com/uesteibar/scribano/watcher"
"github.com/uesteibar/scribano/watcher/config"
yamlconfig "github.com/uesteibar/scribano/watcher/config/parsers/yaml_config"
"github.com/uesteibar/scribano/web/api"
)
func getLoader() config.Loader {
var url string
flag.StringVar(&url, "u", "", "url to the config file.")
var path string
flag.StringVar(&path, "f", "", "path to the config file.")
flag.Parse()
if url != "" {
return &config.URLLoader{Source: url}
} else if path != "" {
return &config.PathLoader{Source: path}
} else {
panic("Missing configuration")
}
}
func main() {
repo := messagesrepo.New(db.DB{})
repo.Migrate()
loader := getLoader()
configParser := yamlconfig.New(loader)
configs, err := configParser.Parse()
if err != nil {
panic(err)
}
for _, c := range configs {
w := watcher.New(c, 5) // consume 5% of messages
go w.Watch()
}
api.Start()
}