load

package
v0.70.0-beta Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstWorkerTicker

type ConstWorkerTicker struct {
	C chan TickValue
	N uint
}

ConstWorkerTicker is the const worker

func (*ConstWorkerTicker) Finish

func (c *ConstWorkerTicker) Finish()

Finish stops

func (*ConstWorkerTicker) Run

func (c *ConstWorkerTicker) Run()

Run runs the ticker

func (*ConstWorkerTicker) Ticker

func (c *ConstWorkerTicker) Ticker() <-chan TickValue

Ticker returns the ticker channer

type ConstantPacer

type ConstantPacer struct {
	Freq uint64 // Frequency of hits per second
	Max  uint64 // Optional maximum allowed hits
}

A ConstantPacer defines a constant rate of hits for the target.

func (*ConstantPacer) Pace

func (cp *ConstantPacer) Pace(elapsed time.Duration, hits uint64) (time.Duration, bool)

Pace determines the length of time to sleep until the next hit is sent.

func (*ConstantPacer) Rate

func (cp *ConstantPacer) Rate(elapsed time.Duration) float64

Rate returns a ConstantPacer's instantaneous hit rate (i.e. requests per second) at the given elapsed duration of an attack. Since it's constant, the return value is independent of the given elapsed duration.

func (*ConstantPacer) String

func (cp *ConstantPacer) String() string

String returns a pretty-printed description of the ConstantPacer's behaviour:

ConstantPacer{Freq: 1} => Constant{1 hits/1s}

type LineWorkerTicker

type LineWorkerTicker struct {
	C chan TickValue

	Start        uint
	Slope        int
	Stop         uint
	LoadDuration time.Duration
	// contains filtered or unexported fields
}

LineWorkerTicker is the worker ticker that implements line adjustments to concurrency

func (*LineWorkerTicker) Finish

func (c *LineWorkerTicker) Finish()

Finish stops

func (*LineWorkerTicker) Run

func (c *LineWorkerTicker) Run()

Run runs the ticker

func (*LineWorkerTicker) Ticker

func (c *LineWorkerTicker) Ticker() <-chan TickValue

Ticker returns the ticker channer

type LinearPacer

type LinearPacer struct {
	Start        ConstantPacer
	Slope        int64
	Stop         ConstantPacer
	LoadDuration time.Duration
	Max          uint64
	// contains filtered or unexported fields
}

LinearPacer paces an attack by starting at a given request rate and increasing linearly with the given slope.

func (*LinearPacer) Pace

func (p *LinearPacer) Pace(elapsed time.Duration, hits uint64) (time.Duration, bool)

Pace determines the length of time to sleep until the next hit is sent.

func (*LinearPacer) Rate

func (p *LinearPacer) Rate(elapsed time.Duration) float64

Rate returns a LinearPacer's instantaneous hit rate (i.e. requests per second) at the given elapsed duration of an attack.

func (*LinearPacer) String

func (p *LinearPacer) String() string

String returns a pretty-printed description of the LinearPacer's behaviour:

LinearPacer{Slope: 1} => Linear{1 hits/1s}

type Pacer

type Pacer interface {
	// Pace returns the duration the attacker should wait until
	// making next hit, given an already elapsed duration and
	// completed hits. If the second return value is true, an attacker
	// should stop sending hits.
	Pace(elapsed time.Duration, hits uint64) (wait time.Duration, stop bool)

	// Rate returns a Pacer's instantaneous hit rate (per seconds)
	// at the given elapsed duration of an attack.
	Rate(elapsed time.Duration) float64
}

A Pacer defines the control interface to control the rate of hit.

type StepPacer

type StepPacer struct {
	Start        ConstantPacer
	Step         int64
	StepDuration time.Duration
	Stop         ConstantPacer
	LoadDuration time.Duration
	Max          uint64
	// contains filtered or unexported fields
}

StepPacer paces an attack by starting at a given request rate and increasing with steps at a given time interval and duration.

func (*StepPacer) Pace

func (p *StepPacer) Pace(elapsed time.Duration, hits uint64) (time.Duration, bool)

Pace determines the length of time to sleep until the next hit is sent.

func (*StepPacer) Rate

func (p *StepPacer) Rate(elapsed time.Duration) float64

Rate returns a StepPacer's instantaneous hit rate (i.e. requests per second) at the given elapsed duration of an attack.

func (*StepPacer) String

func (p *StepPacer) String() string

String returns a pretty-printed description of the StepPacer's behaviour:

StepPacer{Step: 1, StepDuration: 5s} => Step{1 hits/5s}

type StepWorkerTicker

type StepWorkerTicker struct {
	C chan TickValue

	Start        uint
	Step         int
	StepDuration time.Duration
	Stop         uint
	LoadDuration time.Duration
}

StepWorkerTicker is the worker ticker that implements step adjustments to concurrency

func (*StepWorkerTicker) Finish

func (c *StepWorkerTicker) Finish()

Finish stops

func (*StepWorkerTicker) Run

func (c *StepWorkerTicker) Run()

Run runs the ticker

func (*StepWorkerTicker) Ticker

func (c *StepWorkerTicker) Ticker() <-chan TickValue

Ticker returns the ticker channer

type TickValue

type TickValue struct {
	Delta int
}

TickValue is the delta value

type WorkerTicker

type WorkerTicker interface {
	Ticker() <-chan TickValue
	Run()
	Finish()
}

WorkerTicker is the interface for worker ticker which controls worker parallelism

Jump to

Keyboard shortcuts

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