benchttp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusRunning  = recorder.StatusRunning
	StatusCanceled = recorder.StatusCanceled
	StatusTimeout  = recorder.StatusTimeout
	StatusDone     = recorder.StatusDone
)

Variables

View Source
var ErrCanceled = recorder.ErrCanceled

Functions

This section is empty.

Types

type InvalidRunnerError

type InvalidRunnerError struct {
	Errors []error
}

InvalidRunnerError is the errors returned by Runner.Validate when values are missing or invalid.

func (*InvalidRunnerError) Error

func (e *InvalidRunnerError) Error() string

Error returns the joined errors of InvalidRunnerError as a string.

type Metadata

type Metadata struct {
	Runner        Runner
	FinishedAt    time.Time
	TotalDuration time.Duration
}

Metadata contains contextual information about a run.

type MetricsAggregate

type MetricsAggregate = metrics.Aggregate

type MetricsField

type MetricsField = metrics.Field

type MetricsTimeStats

type MetricsTimeStats = metrics.TimeStats

type MetricsValue

type MetricsValue = metrics.Value

type RecordingProgress

type RecordingProgress = recorder.Progress

type RecordingStatus

type RecordingStatus = recorder.Status

type Report

type Report struct {
	Metadata Metadata
	Metrics  metrics.Aggregate
	Tests    tests.SuiteResult
}

Report represents a run result as exported by the runner.

type Runner

type Runner struct {
	Request *http.Request

	Requests       int
	Concurrency    int
	Interval       time.Duration
	RequestTimeout time.Duration
	GlobalTimeout  time.Duration

	Tests []tests.Case

	OnProgress func(RecordingProgress)
	// contains filtered or unexported fields
}

func DefaultRunner

func DefaultRunner() Runner

DefaultRunner returns a default Runner that is ready to use, except for Runner.Request that still needs to be set.

func (Runner) Run

func (r Runner) Run(ctx context.Context) (*Report, error)

func (Runner) Validate

func (r Runner) Validate() error

Validate returns a non-nil InvalidConfigError if any of its fields does not meet the requirements.

func (Runner) WithNewRequest

func (r Runner) WithNewRequest(method, uri string, body io.Reader) Runner

WithNewRequest calls http.NewRequest with the given parameters and attaches the result to the Runner. If the call to http.NewRequest returns a non-nil error, it panics with the content of that error.

func (Runner) WithRequest

func (r Runner) WithRequest(req *http.Request) Runner

WithRequest attaches the given HTTP request to the Runner.

type TestCase

type TestCase = tests.Case

type TestCaseResult

type TestCaseResult = tests.CaseResult

type TestPredicate

type TestPredicate = tests.Predicate

type TestSuiteResults

type TestSuiteResults = tests.SuiteResult

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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