Documentation
¶
Overview ¶
Package worker runs the load-generating side of a distributed test. A worker dials out to the server (so it works from behind NAT), registers with a join token, keeps a heartbeat going and runs whatever slice of a scenario the server assigns, streaming one snapshot per interval back.
A worker protects the target on its own: if it loses the server for the dead man's switch timeout (10s) during a run, it stops generating load without waiting to be told.
Index ¶
Constants ¶
const StopDeadMan = "lost contact with server"
StopDeadMan is the stop reason when the dead man's switch fires.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Server is the coordinator address, host:port.
Server string
// Token is the server's join token.
Token string
Name string // default: the host name
Region string
Labels map[string]string
// MaxVUs caps the virtual users this worker accepts (0 = no cap).
MaxVUs int
// CPUs overrides the advertised capacity (default runtime.NumCPU).
// The server splits load in proportion to it.
CPUs int
// Insecure connects without TLS. Otherwise TLS is used with TLS (nil
// means the system roots).
Insecure bool
TLS *tls.Config
// MTLS enrolls with the server's built-in CA and connects with the
// worker's own certificate (servers started with --worker-mtls). The
// join token is then never sent.
MTLS bool
// CAFingerprint pins the server's CA ("sha256:..."). Without it the
// CA is learned at the first enrollment, authenticated by the join
// token, and pinned from then on.
CAFingerprint string
// EnrollDialer replaces the TCP dialer used to enroll (tests).
EnrollDialer interface {
DialContext(ctx context.Context, network, addr string) (net.Conn, error)
}
// Gate, shared by the Workers of one process that connect to several
// server replicas, lets only one of them run load at a time.
Gate *Gate
// DialOptions are added to the gRPC dial options (tests dial bufconn).
DialOptions []grpc.DialOption
// DeadManTimeout stops load when the server has not been heard from
// for this long during a run (default 10s).
DeadManTimeout time.Duration
// Thresholds for self-reported saturation (default DefaultThresholds).
Thresholds *health.Thresholds
// HTTP overrides engine HTTP options (tests, network emulation).
HTTP httpx.Options
// PluginDir is where plugins are looked for before PATH (default
// $STAMPEDE_PLUGIN_DIR or the user config directory).
PluginDir string
// Clock is the worker's wall clock (default time.Now). Tests use it to
// simulate workers whose clocks disagree with the server's.
Clock func() time.Time
Logger *slog.Logger
// OnRunStart, when set, is called with each run's start time T0
// converted to this process's time.Now clock.
OnRunStart func(runID string, t0 time.Time)
// OnStop, when set, is called when the worker stops a run on the
// server's request or by its dead man's switch.
OnStop func(runID string, kill bool, reason string)
}
Config configures a worker.
type Gate ¶
type Gate struct {
// contains filtered or unexported fields
}
Gate lets the Workers of one process (one per server replica, see Config.Gate) share the machine: only one of them runs load at a time. A nil Gate allows everything.