Documentation
¶
Overview ¶
Package loadgen is a small, stdlib-only client-side HTTP load generator (ADR-0053). It drives a target URL with concurrent workers (closed model) and reports throughput + tail latency — the engine behind `funcdctl bench` (the funcd analogue of `nats bench`).
It is deliberately HAND-ROLLED on the standard library — net/http + sort + sync — so the shipped funcdctl binary carries no benchmarking dependency: ADR-0051 confines gopsutil/fortio to the funcd-bench harness, and this package keeps that true (it must NEVER import them). It is a client tool, not the funcd-bench embed/memory harness (ADR-0040/0052).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
URL string
Method string // default POST
Body string // request body, sent as-is each request
ContentType string // default application/json
Concurrency int // worker goroutines (default 8)
Duration time.Duration // closed-model run length (used when Requests == 0; default 5s)
Requests int // total requests across workers; 0 ⇒ use Duration
}
Options configures a load run.
type Result ¶
type Result struct {
Total int `json:"total"`
OK int `json:"ok"`
Errors int `json:"errors"`
Duration time.Duration `json:"duration"` // actual elapsed wall-clock of the run
RPS float64 `json:"rps"` // OK / Duration.Seconds()
P50 time.Duration `json:"p50"`
P90 time.Duration `json:"p90"`
P99 time.Duration `json:"p99"`
Max time.Duration `json:"max"`
}
Result is the measured outcome of a run.
func Run ¶
Run drives o.URL under load and returns the measured Result. It honors ctx cancellation. Transport failures (connection refused, timeout, non-2xx) are counted in Result.Errors — they are NOT returned; the only returned error is a usage problem (empty URL). The caller decides whether OK==0 is fatal.