|
@@ -53,12 +53,14 @@ var (
|
|
|
hostName = flag.String("hostname", "", "Override the captured hostname with this one")
|
|
|
accessWatchKey = flag.String("access-watch-key", "", "access.watch API key")
|
|
|
configFile = flag.String("config", "", "The location of the TOML config file")
|
|
|
+ rpcAddr = flag.String("rpc-address", "", "The address where the RPC server is listening")
|
|
|
|
|
|
beQuiet = flag.Bool("quiet", true, "Be quiet")
|
|
|
doVersion = flag.Bool("version", false, "Show version information")
|
|
|
|
|
|
natsEC *nats.EncodedConn
|
|
|
natsJSONEC *nats.EncodedConn
|
|
|
+ rpcClient *ScwRPC
|
|
|
natsErrorChan chan error
|
|
|
natsIsAvailable bool
|
|
|
count uint64
|
|
@@ -98,6 +100,7 @@ type Config struct {
|
|
|
NginxReplay string
|
|
|
HostName string
|
|
|
AccessWatchKey string
|
|
|
+ RPCAddress string
|
|
|
}
|
|
|
|
|
|
type duration struct {
|
|
@@ -132,6 +135,7 @@ func (c Config) print() {
|
|
|
fmt.Printf("AccessWatchKey: %s\n", c.AccessWatchKey)
|
|
|
fmt.Printf("UseXForwardedAsSource: %t\n", c.UseXForwardedAsSource)
|
|
|
fmt.Printf("Protocol: %s\n", c.Protocol)
|
|
|
+ fmt.Printf("RPCAddress: %s\n", c.RPCAddress)
|
|
|
fmt.Printf("Quiet: %t\n", c.Quiet)
|
|
|
fmt.Printf("Trace: %t\n", c.Trace)
|
|
|
}
|
|
@@ -177,6 +181,15 @@ func main() {
|
|
|
|
|
|
go natsWatchdog(natsErrorChan)
|
|
|
|
|
|
+ // RPC
|
|
|
+ //
|
|
|
+ if config.RPCAddress != "" {
|
|
|
+ rpcClient, err = NewScwRPC(config.RPCAddress)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// What should I do?
|
|
|
if config.RequestsFile != "" {
|
|
|
replayFile()
|
|
@@ -352,6 +365,14 @@ func publishRequest(queue string, request *data.Request) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if rpcClient != nil {
|
|
|
+ select {
|
|
|
+ case rpcClient.RChan <- request:
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if !natsIsAvailable {
|
|
|
if rand.Intn(100) == 0 {
|
|
|
log.Println("nats connection is not available")
|
|
@@ -687,6 +708,7 @@ func loadConfig() {
|
|
|
config.Quiet = *beQuiet
|
|
|
config.Trace = *trace
|
|
|
config.AccessWatchKey = *accessWatchKey
|
|
|
+ config.RPCAddress = *rpcAddr
|
|
|
|
|
|
if *configFile == "" {
|
|
|
return
|