biz

package
v0.0.0-...-1b17b00 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const KST int = 3

Variables

Functions

This section is empty.

Types

type ConstantPacer

type ConstantPacer struct {
	Freq int           // Frequency (number of occurrences) per ...
	Per  time.Duration // Time unit, usually 1s
}

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, Per: time.Second} => Constant{1 hits/1s}

type DynamicParam

type DynamicParam struct {
	Headers map[string]string
	Query   map[string]string
	Body    string
}

type LinearPacer

type LinearPacer struct {
	StartAt Rate
	Slope   float64
}

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.

type Pacer

type Pacer interface {
	// Pace returns the duration an Attacker should wait until
	// hitting the next Target, 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
}

Pacer refer: https://github.com/tsenart/vegeta/blob/master/lib/pacer.go Pacer A Pacer defines the rate of hits during an Attack.

type PacerFunc

type PacerFunc func(time.Duration, uint64) (time.Duration, bool)

A PacerFunc is a function adapter type that implements the Pacer interface.

func (PacerFunc) Pace

func (pf PacerFunc) Pace(elapsed time.Duration, hits uint64) (time.Duration, bool)

Pace implements the Pacer interface.

type Rate

type Rate = ConstantPacer

Rate is a type alias for ConstantPacer for backwards-compatibility.

type Requester

type Requester struct {
	PlanId              uint64
	TaskId              uint64
	StressType          int32
	StressMode          int32
	Num                 int32
	StepIntervalTime    int32
	Nums                []int32
	MaxConnections      int32
	MaxIdleConnections  int32
	StressTime          int32
	Timeout             int32
	Method              string
	Url                 string
	Headers             map[string]string
	Query               string
	Body                string
	DynamicParams       []*DynamicParam
	ResponseCheckScript string

	DisableKeepAlive bool
	H2               bool
	MaxBodySize      int64

	DisableCompression bool
	DisableRedirects   bool
	Proxy              string

	Addr string

	// Writer is where results will be written. If nil, results are written to stdout.
	Writer io.Writer

	StartTime int64
	// contains filtered or unexported fields
}

type RequesterUsecase

type RequesterUsecase struct {
	// contains filtered or unexported fields
}

func NewRequesterUsecase

func NewRequesterUsecase(conf *conf.ServerConf, queRepository repo.QueRepository, nodeRepository repo.NodeRepository, discovery registry.Discovery) *RequesterUsecase

func (*RequesterUsecase) Request

func (b *RequesterUsecase) Request(ctx context.Context, r *Requester) error

func (*RequesterUsecase) Stop

func (b *RequesterUsecase) Stop(ctx context.Context, planId uint64, taskId uint64) error

Jump to

Keyboard shortcuts

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