worker

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

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

View Source
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 New

func New(cfg Config) (*Worker, error)

New prepares a worker. It does not connect; Run does that.

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

func (w *Worker) OnAccepted(_ context.Context, msg *loadwavev1.Accepted) error

OnAccepted implements control.Handler.

func (*Worker) OnSetQuota

func (w *Worker) OnSetQuota(_ context.Context, msg *loadwavev1.SetQuota) error

OnSetQuota implements control.Handler.

func (*Worker) OnStartRun

func (w *Worker) OnStartRun(_ context.Context, msg *loadwavev1.StartRun) error

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.

func (*Worker) OnStopRun

func (w *Worker) OnStopRun(_ context.Context, msg *loadwavev1.StopRun) error

OnStopRun implements control.Handler.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Run joins the agent and serves until the context is cancelled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL