diff --git a/cmd/zload/main.go b/cmd/zload/main.go index e0b420c..a238fb6 100644 --- a/cmd/zload/main.go +++ b/cmd/zload/main.go @@ -19,6 +19,7 @@ import ( "context" "flag" "fmt" + "io" "math/rand" "net/http" "net/http/cookiejar" @@ -93,12 +94,16 @@ func newSession() (*http.Client, error) { } func post(c *http.Client, path, body string) (int, error) { - req, _ := http.NewRequest("POST", *addr+path, strings.NewReader(body)) + req, err := http.NewRequest("POST", *addr+path, strings.NewReader(body)) + if err != nil { + return 0, err + } req.Header.Set("Content-Type", "application/json") resp, err := c.Do(req) if err != nil { return 0, err } + io.Copy(io.Discard, resp.Body) // drain so the connection can be reused resp.Body.Close() return resp.StatusCode, nil } @@ -120,7 +125,7 @@ func reader(ctx context.Context, st *stats, observe bool) { } defer resp.Body.Close() - var src = brotli.NewReader(resp.Body) + src := brotli.NewReader(resp.Body) sc := bufio.NewScanner(src) sc.Buffer(make([]byte, 0, 64*1024), 1024*1024) seen := map[int64]bool{} diff --git a/tasks/prelaunch-checklist.md b/tasks/prelaunch-checklist.md index c5d0071..b56ff5b 100644 --- a/tasks/prelaunch-checklist.md +++ b/tasks/prelaunch-checklist.md @@ -113,7 +113,7 @@ Verified clean at review time: `go vet ./...`, `gofmt -l .`, `go test -race ./.. - [x] **P4.2 Concurrency test coverage** — `helpers_test.go` covers pure functions only; nothing exercises the Writer (batching/savepoint rollback/queue-full — would have caught P0.1), cache invalidation across version bumps, or hub frame/sweep/eviction. Add a test hammering `Writer.Submit` from N goroutines while readers hit the caches, run under `-race`. -- [ ] **P4.3 `zload` harness nits** — `cmd/zload/main.go:95,123`: `post` ignores `http.NewRequest` error and doesn't drain bodies on non-2xx; `var src =` → `:=`. Fine for a harness; fix opportunistically. +- [x] **P4.3 `zload` harness nits** — `cmd/zload/main.go:95,123`: `post` ignores `http.NewRequest` error and doesn't drain bodies on non-2xx; `var src =` → `:=`. Fine for a harness; fix opportunistically. ---