dynconfig

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dynconfig fetches and holds the boomer worker's runtime-mutable settings — the subset of locust flags the operator can change in the web UI form. The boomer wire protocol only carries num_users + spawn_rate, so these come over an HTTP side channel from the master's /boomer-config endpoint (common/boomer_config.py).

Index

Constants

View Source
const (
	ResumeModeExplicit = "explicit"
	ResumeModeImplicit = "implicit"

	ReadModeData   = "data"
	ReadModeDigest = "digest"
)

Resume modes. Explicit issues a ResumeActor RPC before sending traffic. Implicit issues no wake request at all: the actor stays suspended until a request reaches the atenet router, which wakes it while the request is parked.

Variables

This section is empty.

Functions

func StartPoll

func StartPoll(
	ctx context.Context,
	url string,
	holder *Holder,
	sampler ProbabilityUpdater,
	interval, fetchTimeout time.Duration,
	onError func(error),
)

StartPoll fetches `url` every `interval` until `ctx` is done, and applies each change to `holder` + `sampler`. It returns at once; the loop is in a goroutine. An interval of zero or less starts no loop.

SubscribeSpawn below is not sufficient by itself. Locust sends a spawn message only when the number of users or the spawn rate changes, thus a step of a load shape that changes the sample rate and holds the number of users gives no message, and the worker keeps the value of the step before it. The sample-rate sweep of benchmarking/observability.md is one such shape: each of its steps holds 10 users.

`onError` gets each failed fetch. A caller must not exit the process there, as it does for a spawn: the worker holds the last good value, and one failed poll of a long run is not a reason to lose the run.

func SubscribeSpawn

func SubscribeSpawn(url string, holder *Holder, sampler ProbabilityUpdater, fetchTimeout time.Duration, onError func(error)) error

SubscribeSpawn registers a boomer Events handler that fetches `url` on each spawn message (≈ once per test start) and applies the result to `holder` + `sampler`. `onError` is invoked when a fetch fails; production callers typically exit the process there per the "treat as fatal" design. Returns an error if the event subscription itself fails (handler signature mismatch), which is a programmer error and should be treated as fatal too.

Types

type Config

type Config struct {
	MinWait          time.Duration
	MaxWait          time.Duration
	TraceProbability float64
	DurDirFileSize   int64  // bytes
	ResumeMode       string // ResumeModeExplicit | ResumeModeImplicit
	DurDirReadMode   string // ReadModeData | ReadModeDigest
	DurDirTemplate   string // ActorTemplate name
	MemTarget        string // resident RAM the GluttonUser fills via WriteRAM, suffixed (e.g. "2Gi"); "" disables
	MemChurn         string // RAM re-randomized in place each cycle via WriteRAM rotate, suffixed (e.g. "64Mi"); "" disables
	MemRead          string // RAM walked (one byte per page) via ReadRAM after each resume, suffixed (e.g. "1Gi") or "all"; "" disables
}

Config is the dynamic-mutable subset of boomer's behavior. Holder swaps it atomically so task goroutines read a consistent snapshot.

func Fetch

func Fetch(ctx context.Context, url string, current Config) (Config, error)

Fetch GETs `url` and merges any returned fields into `current`. Returns the merged Config (or current unchanged on a soft no-op response).

func Parse

func Parse(jsonBytes []byte, current Config) (Config, error)

Parse decodes a JSON blob (typically from a CLI flag) and merges its fields into `current`. Returns the merged Config — unset fields preserve `current`'s existing values, matching Fetch's behavior.

func (Config) Validate

func (c Config) Validate() error

Validate checks that the config values are within legal ranges.

type Holder

type Holder struct {
	// contains filtered or unexported fields
}

Holder lets readers Load() the current Config and writers Store() a new one. Backed by atomic.Pointer for lock-free reads on the hot path.

func NewHolder

func NewHolder(initial Config) *Holder

func (*Holder) Load

func (h *Holder) Load() Config

func (*Holder) Store

func (h *Holder) Store(c Config)

type ProbabilityUpdater

type ProbabilityUpdater interface {
	UpdateProbability(p float64)
}

ProbabilityUpdater is the subset of trace.UpdatableSampler we touch here; kept as an interface so this package doesn't depend on the trace package.

Jump to

Keyboard shortcuts

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