-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 868 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"
log "github.com/sirupsen/logrus"
"hpor/rpc"
"os"
)
var t = flag.String("t", "RP", "RPC or PROXY or RP")
var amqp = flag.String("url", "amqp://guest:[email protected]:5672/", "amqp address")
var port = flag.Int("p", 8000, "HTTP proxy port")
var count = flag.Int("c", 1, "The number of consumers,work with -t RPC")
var debug = flag.Bool("d", false, "log debug info")
var queueName = flag.String("q", "rpc_queue", "The queue name for rpc")
func main() {
flag.Parse()
log.SetOutput(os.Stdout)
if *debug {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
conf := &rpc.Config{
Amqp: *amqp,
Port: *port,
QueueName: *queueName,
}
log.Info("start app as ", *t)
if *t == "RPC" {
rpc.Accept(conf, *count)
} else if *t == "RP" {
rpc.ReverseProxy(conf)
} else {
rpc.Proxy(conf)
}
}