Documentation ¶
Overview ¶
Package locust implements a locust client using native Go data structures Locust API https://docs.locust.io/en/stable/api.html# Locust endpoints https://github.com/locustio/locust/blob/master/locust/web.py
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client defines a structure for a locust client. Client contains URL of the locust endpoint and a httpclient
func New ¶
New initiantes a new client to control locust, url of the locust endpoint is required as a paramenter
func (*Client) GenerateLoad ¶
func (c *Client) GenerateLoad(users int, hatchrate float64) (*SwarmResponse, error)
GenerateLoad starts locust swarming or modifes if the load generation has already started, hatch rate and number of users to simulate are inputs.
func (*Client) Stats ¶
func (c *Client) Stats() (*StatsResponse, error)
Stats gets the execution metrics from locust this provides error ratio, current users hatchd, state and many other defined in StatsResponse structure
func (*Client) StopLoad ¶
func (c *Client) StopLoad() (*SwarmResponse, error)
StopLoad stops an existing locust execution
type Error ¶
type Error struct { Error string `json:"error"` Method string `json:"method"` Name string `json:"name"` Occurrences int `json:"occurrences"` }
Error defines structure of error records in locust stats from locust stats endpoint, this is part of StatsResponse
type Stat ¶
type Stat struct { AvgContentLength float64 `json:"avg_content_length"` AvgResponseTime float64 `json:"avg_response_time"` CurrentRps float64 `json:"current_rps"` MaxResponseTime float64 `json:"max_response_time"` MedianResponseTime float64 `json:"median_response_time"` Method string `json:"method"` MinResponseTime float64 `json:"min_response_time"` Name string `json:"name"` NumFailures int `json:"num_failures"` NumRequests int `json:"num_requests"` }
Stat defines locust stats structure from locust stats endpoint, this is part of StatsResponse
type StatsResponse ¶
type StatsResponse struct { CurrentResponseTimePercentile50 float64 `json:"current_response_time_percentile_50"` CurrentResponseTimePercentile95 float64 `json:"current_response_time_percentile_95"` Errors []Error `json:"errors"` FailRatio float64 `json:"fail_ratio"` State string `json:"state"` Statistics []Stat `json:"stats"` TotalRps float64 `json:"total_rps"` UserCount int `json:"user_count"` }
StatsResponse defines the structure for the response from locust stats endpoint.
type SwarmResponse ¶
SwarmResponse defines the structure of a response for locust swarm endpoint Locust returns a json with status of the action and a message. start and stop locust swarming both returns a message with same structure.