diff options
Diffstat (limited to 'internal/clients/grepclient.go')
| -rw-r--r-- | internal/clients/grepclient.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/internal/clients/grepclient.go b/internal/clients/grepclient.go index 7521c67..72b4248 100644 --- a/internal/clients/grepclient.go +++ b/internal/clients/grepclient.go @@ -2,9 +2,7 @@ package clients import ( "errors" - "fmt" "runtime" - "strings" "github.com/mimecast/dtail/internal/clients/handlers" "github.com/mimecast/dtail/internal/config" @@ -27,14 +25,18 @@ func NewGrepClient(args config.Args) (*GrepClient, error) { c := GrepClient{ baseClient: baseClient{ + mu: newBaseClientMu(), Args: args, throttleCh: make(chan struct{}, args.ConnectionsPerCPU*runtime.NumCPU()), retry: false, + runtime: newClientRuntimeBoundary(config.CurrentRuntime()), }, } c.init() - c.makeConnections(c) + if err := c.makeConnections(c); err != nil { + return nil, err + } return &c, nil } @@ -42,14 +44,18 @@ func (c GrepClient) makeHandler(server string) handlers.Handler { return handlers.NewClientHandler(server) } +func (c GrepClient) makeSessionSpec() (SessionSpec, error) { + return NewSessionSpec(c.Args), nil +} + func (c GrepClient) makeCommands() (commands []string) { - regex, err := c.Regex.Serialize() + sessionSpec, err := c.makeSessionSpec() if err != nil { - dlog.Client.FatalPanic(err) + dlog.Client.FatalPanic("unable to build grep session spec", err) } - for _, file := range strings.Split(c.What, ",") { - commands = append(commands, fmt.Sprintf("%s:%s %s %s", - c.Mode.String(), c.Args.SerializeOptions(), file, regex)) + commands, err = sessionSpec.Commands() + if err != nil { + dlog.Client.FatalPanic("unable to build grep commands from session spec", err) } - return + return commands } |
