goload

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 13 Imported by: 0

README

goload

Go CI

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunLoadTest

func RunLoadTest(opts ...LoadTestOption)

Types

type ExecutionResponse

type ExecutionResponse struct {
	Identifier     string
	Err            error
	AdditionalData any
}

type Executor

type Executor interface {
	Execute(ctx context.Context) ExecutionResponse
	Name() string
	// TODO: remove pointer and maybe split into two functions
	Options() *ExecutorOptions
}

func NewGenericExecutor added in v0.3.1

func NewGenericExecutor(name string, handler func(ctx context.Context) error, opts ...ExecutorOption) Executor

func WithGroup

func WithGroup(opts ...GroupOption) Executor

type ExecutorOption added in v0.3.1

type ExecutorOption func(options *ExecutorOptions)

func WithTimeout added in v0.3.1

func WithTimeout(timeout time.Duration) ExecutorOption

func WithWeight added in v0.3.1

func WithWeight(weight int) ExecutorOption

type ExecutorOptions

type ExecutorOptions struct {
	Weight  int
	Timeout time.Duration
}

type GroupOption

type GroupOption func(*GroupOptions)

func WithGroupExecutors

func WithGroupExecutors(executors ...Executor) GroupOption

func WithGroupName

func WithGroupName(name string) GroupOption

func WithGroupTimeout

func WithGroupTimeout(timeout time.Duration) GroupOption

func WithGroupWeight

func WithGroupWeight(weight int) GroupOption

type GroupOptions

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

type LoadTest

type LoadTest struct {
	Pacer     pacer.Pacer
	Runner    *Runner
	Executors []Executor
	// contains filtered or unexported fields
}

func (*LoadTest) Run

func (lt *LoadTest) Run(ctx context.Context)

type LoadTestOption

type LoadTestOption func(*LoadTestOptions)

func WithAdditionalResultHandler

func WithAdditionalResultHandler(handler resultHandler) LoadTestOption

func WithConstantPacer

func WithConstantPacer(rate pacer.Rate) LoadTestOption

func WithContextModifier

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

func WithDefaultTimeout

func WithDefaultTimeout(timeout time.Duration) LoadTestOption

func WithDuration

func WithDuration(loadTestDuration time.Duration) LoadTestOption

func WithExecutors

func WithExecutors(executors ...Executor) LoadTestOption

func WithInitialWorkerCount

func WithInitialWorkerCount(count int) LoadTestOption

func WithLinearRampUpPacer

func WithLinearRampUpPacer(startRate, endRate pacer.Rate, rampUpDuration time.Duration) LoadTestOption

func WithMaxWorkerCount

func WithMaxWorkerCount(count int) LoadTestOption

func WithReportInterval

func WithReportInterval(reportInterval time.Duration) LoadTestOption

func WithWeightOverrides

func WithWeightOverrides(overrides map[string]int) LoadTestOption

type LoadTestOptions

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

type Result

type Result struct {
	Identifier     string
	Timestamp      time.Time
	Latency        time.Duration
	Err            error
	AdditionalData any
}

type Runner

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

func NewRunner

func NewRunner(loadTestOptions LoadTestOptions) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, exs []Executor, p pacer.Pacer, du time.Duration) <-chan *Result

func (*Runner) Stop

func (r *Runner) Stop() bool

Stop stops the current execution. The return value indicates whether this call has signalled the execution to stop (`true` for the first call) or whether it was a noop because it has been previously signalled to stop (`false` for any subsequent calls).

Directories

Path Synopsis
utils
ctx

Jump to

Keyboard shortcuts

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