-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
63 lines (57 loc) · 1.72 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
package main
import (
"fmt"
"github.com/devplayg/grpc-server/receiver"
"github.com/devplayg/hippo/v2"
"github.com/spf13/pflag"
"os"
"time"
)
const (
appName = "receiver"
appDescription = "Receiver via gRPC"
appVersion = "1.0.0"
)
var (
fs = pflag.NewFlagSet(appName+" "+appVersion, pflag.ExitOnError)
debug = fs.Bool("debug", false, "Debug") // GODEBUG=http2debug=2
trace = fs.Bool("trace", false, "Trace")
verbose = fs.BoolP("verbose", "v", false, "Verbose")
version = fs.Bool("version", false, "Version")
insecure = fs.Bool("insecure", false, "Disable TLS")
certFile = fs.String("certFile", "server.crt", "SSL Certificate file")
keyFile = fs.String("keyFile", "server.key", "SSL Certificate key file")
batchSize = fs.Int("batchsize", 10000, "Batch size")
batchTimeout = fs.Int("batchtime", 1000, "Batch timeout, in milliseconds")
worker = fs.Int("worker", 0, "Worker count")
monitor = fs.Bool("mon", false, "Monitoring operation on HTTP")
monitorAddr = fs.String("monaddr", ":8901", "Monitoring address")
)
func main() {
config := hippo.Config{
Name: appName,
Description: appDescription,
Version: appVersion,
Debug: *debug,
Trace: *trace,
CertFile: *certFile,
KeyFile: *keyFile,
Insecure: *insecure,
LogDir: ".",
}
if *verbose {
config.LogDir = ""
}
server := receiver.NewReceiver(*batchSize, time.Duration(*batchTimeout)*time.Millisecond, *worker, *monitor, *monitorAddr)
engine := hippo.NewEngine(server, &config)
if err := engine.Start(); err != nil {
panic(err)
}
}
func init() {
_ = fs.Parse(os.Args[1:])
if *version {
fmt.Printf("%s %s\n", appName, appVersion)
os.Exit(0)
}
}