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 ¶
const ( ResumeModeExplicit = "explicit" ResumeModeImplicit = "implicit" ReadModeData = "data" ReadModeDigest = "digest" LifecycleModeSuspend = "suspend" LifecycleModePause = "pause" )
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(err error, fetched bool)) error
SubscribeSpawn registers a boomer Events handler that fetches `url` on each spawn message and applies the result to `holder` + `sampler`. Locust sends a spawn message for every ramp step, so a long ramp fetches once per second. `onError` is invoked when a fetch fails, with `fetched` true if an earlier spawn fetch succeeded: the holder then still has a value from the master, and the caller can keep running on it. With `fetched` false the worker has only its command-line defaults, and callers typically exit. 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 // gap between one actor's suspend and the VU's next resume, lower bound
MaxWait time.Duration // upper bound of the same gap
MinLive time.Duration // time a GluttonUser actor stays resumed between its first ping and suspend, lower bound
MaxLive time.Duration // upper bound of the live window; zero (the default) suspends right after the ping
TraceProbability float64
DurDirFileSize int64 // bytes
ResumeMode string // ResumeModeExplicit | ResumeModeImplicit
LifecycleMode string // LifecycleModeSuspend | LifecycleModePause
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
MaxPingsPerWake int // cap on pings a GluttonUser sends during one resume/suspend cycle; values < 1 read as 1
SweperfTemplate string // ActorTemplate name for the sweperf workload; "" falls back to default
SweperfTotalSteps int // total steps in trace; 0 falls back to default
SweperfNumCycles int // number of cycles to partition steps into; 0 falls back to default
SweperfPollIntervalMs int // /status poll interval in ms; 0 falls back to default
}
Config is the dynamic-mutable subset of boomer's behavior. Holder swaps it atomically so task goroutines read a consistent snapshot.
func Fetch ¶
Fetch GETs `url` and merges any returned fields into `current`. Returns the merged Config (or current unchanged on a soft no-op response).
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.
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.