summaryrefslogtreecommitdiff
path: root/internal/clients/catclient.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-07-22 23:51:18 +0300
committerPaul Buetow <paul@buetow.org>2026-07-22 23:51:18 +0300
commit849951be1d1a7ee9f9302006ccb187bf5b4e36f3 (patch)
tree496c924a03a9ea6212e29bb4699e268066ebad81 /internal/clients/catclient.go
parentbf78b3abffee6d49c08ca2980156afc455994969 (diff)
feat: DTail fork — server/client feature development
Squashed development of the snonux/dtail fork's product code (internal/, cmd/) since diverging from mimecast/dtail. Major areas: - Read/output path: the former "turbo" channel-less path is now the single, default server-side read/output path for cat/grep/tail and MapReduce; the old channel-based path and its config/env toggles were removed. - MapReduce: single aggregate implementation (server + serverless) fed directly by a processor pipeline, with input-exhausted finalization via the shutdown coordinator; high-concurrency and data-race fixes. - Journal source reads (journal:unit.service) via journalctl, Linux-gated behind a journal-v1 capability. - Auth-key fast reconnect: in-memory per-user public-key cache with TTL/max-keys, registered over an authenticated session (AUTHKEY), checked before authorized_keys. - Interactive query reload (--interactive-query) with SESSION START/UPDATE generation boundaries and capability negotiation. - Client-side deadlines: --timeout / --shutdownAfter as context deadlines; follow shutdown handling. - Client logging: diagnostics-only daily log by default, opt-in payload tee via --log-payload. - Numerous correctness fixes (buffer-pool double-recycle races, EOF-sentinel leaks, glob-expansion cap, TOCTOU in CSV parsing) with accompanying unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/clients/catclient.go')
-rw-r--r--internal/clients/catclient.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/internal/clients/catclient.go b/internal/clients/catclient.go
index bd65560..e2e247e 100644
--- a/internal/clients/catclient.go
+++ b/internal/clients/catclient.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"
@@ -26,14 +24,18 @@ func NewCatClient(args config.Args) (*CatClient, error) {
c := CatClient{
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
}
@@ -41,14 +43,18 @@ func (c CatClient) makeHandler(server string) handlers.Handler {
return handlers.NewClientHandler(server)
}
+func (c CatClient) makeSessionSpec() (SessionSpec, error) {
+ return NewSessionSpec(c.Args), nil
+}
+
func (c CatClient) 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 cat 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 cat commands from session spec", err)
}
- return
+ return commands
}