-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (33 loc) · 1019 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
41
42
43
package main
import (
"flag"
"fmt"
"os"
"strings"
)
var (
// FakeTSDB listen port
port = 8089
// Forward to influxDB http api
influxAddress = "http://127.0.0.1:8086"
cache = 3
influxDatabase = "test"
debug = false
)
func init() {
flag.IntVar(&port, "port", port, "Fake proxy listen port.")
flag.IntVar(&cache, "cache", cache, "Number of batch items send to influx.")
flag.StringVar(&influxAddress, "influxAddr", influxAddress, "InfluxDB HTTP API address.")
flag.StringVar(&influxDatabase, "influxDatabase", influxDatabase, "InfluxDB Database.")
flag.BoolVar(&debug, "debug", debug, "Enable debug mode.")
flag.Parse()
if !strings.HasPrefix(influxAddress, "http://") && !strings.HasPrefix(influxAddress, "https://") {
fmt.Println("ERROR: influxAddress must contain a prefix http[s]://")
os.Exit(1)
}
influxRevciver = NewInfluxDBReciver(influxAddress, cache)
influxRevciver.ListenTask()
}
func main() {
NewTSDBServer(fmt.Sprintf("0.0.0.0:%d", port), influxAddress).TcpServer.Listen()
}