Add URL-level concurrency (-c flag, Step 7)

Probe multiple URLs in parallel with a bounded worker pool; the N samples
of each URL remain sequential to preserve accurate min/avg/max statistics.
Default auto-concurrency is min(numURLs, 8); -c 1 restores serial mode.
Output is always buffered and printed in original input order. Verified
clean with go test -race.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 01:33:03 +02:00
parent 45583ac2be
commit 9a69ba946f
9 changed files with 394 additions and 22 deletions

View File

@@ -28,12 +28,16 @@ Both implementations produce identical CLI behaviour and output formats.
latprobe [flags] <url> [url ...]
Flags:
-n, --count int Number of requests per URL (default 1)
--json Output results as JSON instead of text
-n, --count int Number of requests per URL (default 1)
-c, --concurrency int Max URLs probed in parallel, 0 = auto (default min(numURLs,8))
--timeout duration Request timeout, e.g. 10s, 500ms (default 10s)
--fail Exit non-zero on HTTP status >= 400 (exit code 6)
--json Output results as JSON instead of text
Examples:
latprobe https://example.com
latprobe -n 5 https://example.com https://www.google.com
latprobe -c 1 -n 10 https://example.com # serial, most accurate
latprobe --json https://example.com | jq .
```
@@ -96,6 +100,7 @@ https://example.com (5 samples)
| 4 | `--json` output flag | ✅ Done |
| 5 | Failure handling — `--timeout`, `--fail`, distinct exit codes, partial timing | ✅ Done |
| 6 | Integration tests — in-process matrix + subprocess smoke tests | ✅ Done |
| 7 | Concurrency — `-c` worker pool across URLs; samples stay serial per URL | ✅ Done |
### Python
@@ -116,9 +121,10 @@ make test # run all tests
make check # fmt + vet + test (pre-commit gate)
make go-run ARGS="https://example.com"
make go-test-verbose
make go-cover # coverage report → go/coverage.html
make go-lint # golangci-lint
make clean # remove build artifacts
make go-cover # coverage report → go/coverage.html
make go-test-race # run tests with race detector
make go-lint # golangci-lint
make clean # remove build artifacts
```
See [`docs/usage/makefile.md`](docs/usage/makefile.md) for the full target reference.