mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Allow specify global service (useful via env vars)
This commit is contained in:
+2
-2
@@ -6,8 +6,8 @@ import (
|
||||
|
||||
// DummyInput used for debugging. It generate 1 "GET /"" request per second.
|
||||
type DummyInput struct {
|
||||
data chan []byte
|
||||
quit chan struct{}
|
||||
data chan []byte
|
||||
quit chan struct{}
|
||||
Service string
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -51,6 +51,10 @@ func extractLimitOptions(options string) (string, string) {
|
||||
//
|
||||
// See this article if curious about reflect stuff below: http://blog.burntsushi.net/type-parametric-functions-golang
|
||||
func (plugins *InOutPlugins) registerPlugin(service string, constructor interface{}, options ...interface{}) {
|
||||
if service == "" && Settings.Service != "" {
|
||||
service = Settings.Service
|
||||
}
|
||||
|
||||
var path, limit string
|
||||
vc := reflect.ValueOf(constructor)
|
||||
|
||||
@@ -71,7 +75,7 @@ func (plugins *InOutPlugins) registerPlugin(service string, constructor interfac
|
||||
// Calling our constructor with list of given options
|
||||
plugin := vc.Call(vo)[0].Interface()
|
||||
fmt.Sprintf("%#v", vc.Call(vo)[0].Interface())
|
||||
// reflect.ValueOf(plugin).Elem().FieldByName("Service").SetString(service)
|
||||
reflect.ValueOf(plugin).Elem().FieldByName("Service").SetString(service)
|
||||
|
||||
if limit != "" {
|
||||
plugin = NewLimiter(plugin, limit)
|
||||
|
||||
@@ -73,6 +73,7 @@ type ServiceSettings struct {
|
||||
|
||||
type AppSettings struct {
|
||||
ServiceSettings `mapstructure:",squash"`
|
||||
Service string `mapstructure:",service"`
|
||||
|
||||
Services map[string]ServiceSettings `json:"services" mapstructure:"services"`
|
||||
}
|
||||
@@ -98,6 +99,8 @@ func init() {
|
||||
Settings.ExitAfter = 5 * time.Minute
|
||||
}
|
||||
|
||||
flag.StringVar(&Settings.Service, "service", "", "Identified of currenlty capture service. Can be used if you need to record and replay mutiple services at once.")
|
||||
|
||||
flag.BoolVar(&Settings.SplitOutput, "split-output", false, "By default each output gets same traffic. If set to `true` it splits traffic equally among all outputs.")
|
||||
flag.BoolVar(&Settings.RecognizeTCPSessions, "recognize-tcp-sessions", false, "[PRO] If turned on http output will create separate worker for each TCP session. Splitting output will session based as well.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user