Documentation
¶
Overview ¶
Package httpapi serves the LoadWave dashboard and its REST and WebSocket interfaces.
The same surface backs the browser UI and any script that wants to drive a run from CI, which is deliberate: anything the dashboard can do should be automatable without it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Addr is the listen address, such as ":8088".
Addr string
// Coordinator supplies the data and receives the commands.
Coordinator *coordinator.Coordinator
Logger *slog.Logger
// AllowedOrigins lists the browser origins permitted to open a WebSocket.
// Empty means same-origin only, which is what a normal deployment wants;
// the frontend dev server needs its own origin added.
AllowedOrigins []string
// ReadOnly refuses every mutating request. Useful when exposing a live
// run to an audience who should not be able to stop it.
ReadOnly bool
// OnShutdown ends the whole process, if the deployment allows it.
//
// Separate from stopping a run on purpose. Stopping a run has to leave
// the coordinator up — the operator still wants the results, the report,
// and usually another run — so shutting down needs its own deliberate
// action rather than being a side effect of the last run ending.
//
// Nil disables the endpoint.
OnShutdown func(reason string)
// Registry holds the scenarios compiled into this binary.
//
// Needed so that validation can tell a configuration referring to a Go
// scenario this binary does not have from one that is merely misspelled —
// a distinction the scenario builder has no other way to make.
Registry *loadwave.Registry
}
Config describes the dashboard server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the dashboard and API.
type ValidateResult ¶
type ValidateResult struct {
Valid bool `json:"valid"`
// Error is the parser's own message, verbatim, when the configuration is
// rejected. It carries the offending line and field, which is far more
// use to somebody editing a form than a reworded summary would be.
Error string `json:"error,omitempty"`
Summary *ValidateSummary `json:"summary,omitempty"`
}
ValidateResult is the answer to "would this configuration run?".
type ValidateScenario ¶
type ValidateScenario struct {
Name string `json:"name"`
Weight int `json:"weight"`
Description string `json:"description,omitempty"`
// Steps is zero for a scenario compiled into the binary.
Steps int `json:"steps"`
// Source is "yaml" for a scenario defined by steps here, "go" for one
// compiled in.
Source string `json:"source"`
}
ValidateScenario is one scenario as the runner would see it.
type ValidateSummary ¶
type ValidateSummary struct {
Name string `json:"name"`
BaseURL string `json:"baseURL,omitempty"`
Profile string `json:"profile"`
PeakVUs int `json:"peakVUs"`
DurationSeconds float64 `json:"durationSeconds"`
Iterations uint64 `json:"iterations,omitempty"`
IterationRate int `json:"iterationRate,omitempty"`
WorkersPerAgent int `json:"workersPerAgent,omitempty"`
BetweenRequests string `json:"betweenRequests"`
PacingDefaulted bool `json:"pacingDefaulted"`
Scenarios []ValidateScenario `json:"scenarios"`
Thresholds []string `json:"thresholds,omitempty"`
}
ValidateSummary describes what the configuration would actually do.
This is the same information `loadwave validate` prints. Showing it back is how a builder proves it understood the form the same way the runner will: a profile that reads "30s to 100 VUs, then 5m0s to 100 VUs" is a much stronger confirmation than a green tick.