goload

package module
v0.0.0-...-7f6ced5 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 14 Imported by: 0

README

goload

Go CI

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLoadtest

func RunLoadtest(configs ...LoadTestConfig)

Types

type Endpoint

type Endpoint interface {
	// Do performs one request and is executed in a separate goroutine.
	// The context is used to cancel the request on timeout.
	Execute(ctx context.Context) error

	Name() string

	Options() *EndpointOptions
}

func NewEndpoint

func NewEndpoint(name string, handler func(ctx context.Context) error, opts ...EndpointOption) Endpoint

type EndpointOption

type EndpointOption func(options *EndpointOptions)

func WithRequestsPerMinute

func WithRequestsPerMinute(requestsPerMinute int32) EndpointOption

func WithTimeout

func WithTimeout(timeout time.Duration) EndpointOption

type EndpointOptions

type EndpointOptions struct {
	RequestsPerMinute *int32
	Timeout           time.Duration
}

func (*EndpointOptions) Apply

func (options *EndpointOptions) Apply(opts ...EndpointOption)

type EndpointRandomizer

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

func NewEndpointRandomizer

func NewEndpointRandomizer(endpoints []Endpoint, overrides map[string]int32) (*EndpointRandomizer, error)

func (*EndpointRandomizer) PickRandomEndpoint

func (r *EndpointRandomizer) PickRandomEndpoint() Endpoint

type EndpointResult

type EndpointResult struct {
	Failed   bool
	Duration time.Duration
}

type EndpointResults

type EndpointResults struct {
	Name string
	// contains filtered or unexported fields
}

func (*EndpointResults) GetAverageDuration

func (e *EndpointResults) GetAverageDuration() float64

func (*EndpointResults) GetTotalFailedRequests

func (e *EndpointResults) GetTotalFailedRequests() uint64

func (*EndpointResults) GetTotalRequests

func (e *EndpointResults) GetTotalRequests() uint64

type LoadTest

type LoadTest struct {
	UI      *UI
	Options *LoadTestOptions
	Results *LoadTestResults
	// contains filtered or unexported fields
}

func (*LoadTest) ListenForAbort

func (loadtest *LoadTest) ListenForAbort()

func (*LoadTest) Run

func (loadtest *LoadTest) Run()

func (*LoadTest) WaitForLoadTestEnd

func (loadtest *LoadTest) WaitForLoadTestEnd()

type LoadTestConfig

type LoadTestConfig func(options *LoadTestOptions)

func WithContextModifier

func WithContextModifier(fn func(ctx context.Context) context.Context) LoadTestConfig

func WithDefaultEndpointTimeout

func WithDefaultEndpointTimeout(timeout time.Duration) LoadTestConfig

func WithDuration

func WithDuration(loadTestDuration time.Duration) LoadTestConfig

func WithEndpoints

func WithEndpoints(endpoints ...Endpoint) LoadTestConfig

func WithRPMStrategy

func WithRPMStrategy(strategy RPMStrategy) LoadTestConfig

func WithRampUpRPM

func WithRampUpRPM(steps []Step) LoadTestConfig

func WithRequestsPerMinuteForEndpoints

func WithRequestsPerMinuteForEndpoints(data map[string]int32) LoadTestConfig

func WithStaticRPM

func WithStaticRPM(rpm int32) LoadTestConfig

type LoadTestOptions

type LoadTestOptions struct {
	Endpoints []Endpoint
	// A config which allows to set the requests per minute for each registered endpoint at a central place
	//
	// This overrides any local endpoint setting where a default RPM value was set
	RequestPerMinutePerEndpoint map[string]int32

	DefaultEndpointTimeout time.Duration

	LoadTestDuration time.Duration

	RPMStrategy RPMStrategy

	ContextModifiers []func(ctx context.Context) context.Context
}

type LoadTestResults

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

func NewResults

func NewResults(endpoints []Endpoint) *LoadTestResults

func (*LoadTestResults) Iter

func (results *LoadTestResults) Iter() []*EndpointResults

func (*LoadTestResults) SaveEndpointResult

func (results *LoadTestResults) SaveEndpointResult(Endpoint Endpoint, result EndpointResult)

type RPMStrategy

type RPMStrategy interface {
	GetRPMForMinute(minute int32) int32
}

An RPM strategy defines how many requests per minute will be sent to the target.

The GetRPMForMinute function will be called every minute and the loadtest will be adjusted as such.

func NewRampUpRPMStrategy

func NewRampUpRPMStrategy(steps []Step) RPMStrategy

func NewStaticRPMStrategy

func NewStaticRPMStrategy(rpm int32) RPMStrategy

type RampUpRPMStrategy

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

func (*RampUpRPMStrategy) GetRPMForMinute

func (strategy *RampUpRPMStrategy) GetRPMForMinute(minute int32) int32

type StaticRPMStrategy

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

A static rpm strategy which outputs a constant request number to the target.

func (*StaticRPMStrategy) GetRPMForMinute

func (strategy *StaticRPMStrategy) GetRPMForMinute(minute int32) int32

type Step

type Step struct {
	Minute int32
	RPM    int32
}

type UI

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

func NewUI

func NewUI(output io.Writer) *UI

func (*UI) PrintAbortMessage

func (ui *UI) PrintAbortMessage()

func (*UI) PrintStartMessage

func (ui *UI) PrintStartMessage()

func (*UI) ReportDecreaseInRPM

func (ui *UI) ReportDecreaseInRPM(rpm int32)

func (*UI) ReportIncreaseInRPM

func (ui *UI) ReportIncreaseInRPM(rpm int32)

func (*UI) ReportInitialRPM

func (ui *UI) ReportInitialRPM(rpm int32)

func (*UI) ReportResults

func (ui *UI) ReportResults(results *LoadTestResults)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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