forked from grafana-cold-storage/metrictank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
45 lines (37 loc) · 1.38 KB
/
Copy pathconfig.go
File metadata and controls
45 lines (37 loc) · 1.38 KB
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 api
import (
"flag"
"net"
"github.com/raintank/dur"
"github.com/raintank/worldping-api/pkg/log"
"github.com/rakyll/globalconf"
)
var (
maxPointsPerReq int
maxDaysPerReq int
logMinDurStr string
logMinDur uint32
Addr string
UseSSL bool
certFile string
keyFile string
)
func ConfigSetup() {
apiCfg := flag.NewFlagSet("http", flag.ExitOnError)
apiCfg.IntVar(&maxDaysPerReq, "max-days-per-req", 365000, "max amount of days range for one request. the default allows 500 series of 2 year each. (0 disables limit")
apiCfg.IntVar(&maxPointsPerReq, "max-points-per-req", 1000000, "max points could be requested in one request. 1M allows 500 series at a MaxDataPoints of 2000. (0 disables limit)")
apiCfg.StringVar(&logMinDurStr, "log-min-dur", "5min", "only log incoming requests if their timerange is at least this duration. Use 0 to disable")
apiCfg.StringVar(&Addr, "listen", ":6060", "http listener address.")
apiCfg.BoolVar(&UseSSL, "ssl", false, "use HTTPS")
apiCfg.StringVar(&certFile, "cert-file", "", "SSL certificate file")
apiCfg.StringVar(&keyFile, "key-file", "", "SSL key file")
globalconf.Register("http", apiCfg)
}
func ConfigProcess() {
logMinDur = dur.MustParseUsec("log-min-dur", logMinDurStr)
//validate the addr
_, err := net.ResolveTCPAddr("tcp", Addr)
if err != nil {
log.Fatal(4, "API listen address is not a valid TCP address.")
}
}