Skip to content

Commit

Permalink
Allow specify global service (useful via env vars)
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed Dec 22, 2020
1 parent 663f758 commit f287efd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions input_dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 5 additions & 1 deletion plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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.")

Expand Down

0 comments on commit f287efd

Please sign in to comment.