-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (73 loc) · 1.43 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"github.com/urfave/cli"
"metrics/bridge/app"
"log"
"os"
)
var (
Version = "0.1.0"
cliApp = cli.NewApp()
)
func init() {
cliApp.Version = Version
cliApp.Name = "metrics-bridge"
cliApp.Usage = "Move metrics from queue to MongoDB"
cliApp.Flags = []cli.Flag{
cli.StringFlag{
Name: "mongo-dsn",
Value: "mongodb://test:[email protected]:27017/admin?connecttimeoutms=1000",
Usage: "MongoDB DSN",
EnvVar: "MONGO_DSN",
},
cli.StringFlag{
Name: "mongo-db",
Value: "days",
Usage: "Mongo database",
EnvVar: "MONGO_DB",
},
cli.StringFlag{
Name: "queue-dsn",
Value: "127.0.0.1:11300",
Usage: "Local queue server ([mqtt://]ip:port)",
EnvVar: "QUEUE_DSN",
},
cli.StringFlag{
Name: "queue-tube",
Value: "metrics",
Usage: "Tube with metrics",
EnvVar: "QUEUE_TUBE",
},
cli.IntFlag{
Name: "batch-size",
Value: 1000,
Usage: "Batch size",
EnvVar: "BATCH_SIZE",
},
cli.IntFlag{
Name: "batch-timeout",
Value: 30,
Usage: "Batch timeout (seconds)",
EnvVar: "BATCH_TIMEOUT",
},
cli.StringFlag{
Name: "log-mode",
Value: "prod",
Usage: "prod/develop",
EnvVar: "LOG_MODE",
},
cli.StringFlag{
Name: "metrics-addr",
Value: ":8090",
Usage: "Metrics addr",
EnvVar: "METRICS_ADDR",
},
}
}
func main() {
cliApp.Action = app.InitApp
err := cliApp.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}