-
Notifications
You must be signed in to change notification settings - Fork 5
/
responser.go
69 lines (57 loc) · 1.75 KB
/
responser.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"context"
"flag"
"github.com/ShugetsuSoft/pixivel-back/common/database/operations"
"github.com/ShugetsuSoft/pixivel-back/common/database/tasktracer"
"github.com/ShugetsuSoft/pixivel-back/common/utils/config"
"github.com/ShugetsuSoft/pixivel-back/common/utils/telemetry"
"github.com/ShugetsuSoft/pixivel-back/modules"
"github.com/ShugetsuSoft/pixivel-back/modules/responser"
"log"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
var configPath string
flag.StringVar(&configPath, "config", "config.yaml", "Config File Path")
flag.Parse()
conf, err := modules.ReadConfig(configPath)
if err != nil {
log.Fatal(err)
}
telemetry.RegisterResponser()
errchan := telemetry.RunLoki(conf.General.Loki, "responser")
go func() {
for err := range errchan {
log.Println(err)
}
}()
go telemetry.RunPrometheus(conf.General.Prometheus)
db, err := modules.NewDB(conf, ctx)
if err != nil {
log.Fatal(err)
}
mq, err := modules.NewMQ(conf)
if err != nil {
log.Fatal(err)
}
ndb, err := modules.NewNB(conf, ctx)
if err != nil {
log.Fatal(err)
}
es, err := modules.NewES(conf, ctx)
if err != nil {
log.Fatal(err)
}
cacheRedis := modules.NewRD(conf.Redis.CacheRedis.URI)
messageRedis := modules.NewRD(conf.Redis.MessageRedis.URI)
ft := messageRedis.NewBloomFilter(config.DatabaseName)
ope := operations.NewDatabaseOperations(ctx, db, ft, es, ndb)
tracer := tasktracer.NewTaskTracer(messageRedis, config.TaskTracerChannel)
resp := responser.NewResponser(conf.Responser.Listen, ope, mq, config.CrawlTaskQueue, conf.General.SpiderRetry, tracer, cacheRedis, conf.Responser.Debug, conf.Responser.Mode, conf.Responser.EnableForceFetch)
err = resp.Run()
if err != nil {
log.Fatal(err)
}
}