Documentation
¶
Overview ¶
Package worker is the process that actually generates load.
A worker joins its local agent over a Unix socket, waits to be told about a run, and then drives a pool of virtual users through the engine. It is a separate OS process on purpose: virtual users are goroutines, and past a few thousand of them one Go runtime's scheduler and garbage collector become the bottleneck rather than the system under test. Splitting the pool across processes buys back that headroom, and means one panicking scenario cannot take the whole generator down with it.
Index ¶
- Constants
- type Config
- type Worker
- func (w *Worker) LogEvent(level loadwavev1.LogLevel, runID, message string, fields map[string]string)
- func (w *Worker) OnAccepted(_ context.Context, msg *loadwavev1.Accepted) error
- func (w *Worker) OnSetQuota(_ context.Context, msg *loadwavev1.SetQuota) error
- func (w *Worker) OnStartRun(_ context.Context, msg *loadwavev1.StartRun) error
- func (w *Worker) OnStopRun(_ context.Context, msg *loadwavev1.StopRun) error
- func (w *Worker) Run(ctx context.Context) error
Constants ¶
const DefaultMaxVUs = 20000
DefaultMaxVUs is the ceiling a worker advertises when the operator has not set one. Well above what a single process is likely to be given, since the coordinator's apportionment is the real control.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// NodeID is unique across the whole run. The agent assigns it.
NodeID string
// AgentTarget is the agent's control socket, as a gRPC target.
AgentTarget string
// Registry holds the scenarios compiled into this binary.
Registry *loadwave.Registry
// MaxVUs caps how many virtual users this worker will accept.
MaxVUs int
Logger *slog.Logger
}
Config describes a worker process.
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker executes one process's share of a run.
func (*Worker) LogEvent ¶
func (w *Worker) LogEvent(level loadwavev1.LogLevel, runID, message string, fields map[string]string)
LogEvent forwards a notable event to the agent, and on to the dashboard.
func (*Worker) OnAccepted ¶
OnAccepted implements control.Handler.
func (*Worker) OnSetQuota ¶
OnSetQuota implements control.Handler.
func (*Worker) OnStartRun ¶
OnStartRun implements control.Handler.
It builds the engine synchronously so that a misconfigured plan is reported as a failure straight away, then hands execution to a goroutine — the control stream's receive loop must stay responsive, not least so that a stop command can still get through.