Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultAttacker = NewAttacker()
DefaultAttacker is the default Attacker used by Attack
Functions ¶
func ReportJSON ¶
ReportJSON writes a computed Metrics struct to as JSON
func ReportPlot ¶
ReportPlot builds up a self contained HTML page with an interactive plot of the latencies of the requests. Built with http://dygraphs.com/
func ReportText ¶
ReportText returns a computed Metrics struct as aligned, formatted text
Types ¶
type Attacker ¶
type Attacker struct {
// contains filtered or unexported fields
}
Attacker is an attack executor, wrapping an http.Client
func (Attacker) AttackConcy ¶
func (Attacker) AttackRate ¶
Attack attacks the passed Targets (http.Requests) at the rate specified for duration time and then waits for all the requests to come back. The results of the attack are put into a slice which is returned.
func (*Attacker) SetRedirects ¶
SetRedirects sets the max amount of redirects the attacker's http client will follow.
func (*Attacker) SetTimeout ¶
SetTimeout sets the client side timeout for each request the attacker makes.
type Metrics ¶
type Metrics struct { Latencies struct { Mean time.Duration `json:"mean"` P50 time.Duration `json:"50th"` // P50 is the 50th percentile upper value P95 time.Duration `json:"95th"` // P95 is the 95th percentile upper value P99 time.Duration `json:"99th"` // P99 is the 99th percentile upper value Max time.Duration `json:"max"` } `json:"latencies"` BytesIn struct { Total uint64 `json:"total"` Mean float64 `json:"mean"` } `json:"bytes_in"` BytesOut struct { Total uint64 `json:"total"` Mean float64 `json:"mean"` } `json:"bytes_out"` Duration time.Duration `json:"duration"` Requests uint64 `json:"requests"` Qps float64 `json:"qps"` Success float64 `json:"success"` StatusCodes map[string]int `json:"status_codes"` Errors []string `json:"errors"` }
Metrics holds the stats computed out of a slice of Results that is used for some of the Reporters
func NewMetrics ¶
NewMetrics computes and returns a Metrics struct out of a slice of Results
type Reporter ¶
Reporter represents any function which takes a slice of Results and generates a report returned as a slice of bytes and an error in case of failure
type Result ¶
type Result struct { Code uint16 Timestamp time.Time Latency time.Duration BytesOut uint64 BytesIn uint64 Error string }
Result represents the metrics defined out of an http.Response generated by each target hit
type Results ¶
type Results []Result
Results is a slice of Result structs with encoding, decoding and sorting behavior attached
func AttackRate ¶
Attack hits the passed Targets (http.Requests) at the rate specified for duration time and then waits for all the requests to come back. The results of the attack are put into a slice which is returned.
Attack is a wrapper around DefaultAttacker.Attack
func (*Results) Decode ¶
Decode reads data from an io.Reader and decodes it into a Results struct returning an error in case of failure
func (Results) Encode ¶
Encode encodes the results and writes it to an io.Writer returning an error in case of failure
type Targets ¶
type Targets []Target
Targets is a slice of Targets which can be shuffled
func NewTargets ¶
NewTargets instantiates Targets from a slice of strings. It sets the passed body and http.Header on all targets.
func NewTargetsFrom ¶
NewTargetsFrom reads targets out of a line separated source skipping empty lines It sets the passed body and http.Header on all targets.