sampler

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHostPathRequestor

func NewHostPathRequestor(host, path string) hostpath

NewNamespaceRequestor returns a new Requestor instance that creates a new http.Request for a given path:

func NewNamespaceRequestor

func NewNamespaceRequestor(host string) namespaceGetter

NewNamespaceRequestor returns a new Requestor instance that creates a new http.Request to query the default namespace:

GET namespaces/default

func NewSampleProducerConsumer

func NewSampleProducerConsumer(client backend.Client, requestor Requestor, checker ResponseChecker,
	collector SampleCollector) sampler.ProducerConsumer

NewSampleProducerConsumer returns a ProducerConsumer, the Producer is capable of generating a new HTTP request and send it to to the given backend server, and the consumer is capable of receiving the result of the request sent and then feed the result to the specified SampleCollector for further analysis.

client: a wired http.Client that can send an HTTP request
 to a given server
requestor: a Requestor that can generate a desired http.Request
 object to be sent to the server.
checker: the ResponseChecker can check the result and determine
 whether this request should be treated as a failure.
collector: user specified SampleCollector that will collect each
 sample result for further analysis.

Types

type KnownError

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

func (KnownError) Category

func (ke KnownError) Category() string

func (KnownError) Error

func (ke KnownError) Error() string

func (KnownError) Unwrap

func (ke KnownError) Unwrap() error

type Requestor

type Requestor interface {
	// GetBaseURL returns the base URL of the request that is sent to the server.
	// NOTE: we need this to support the the existing BackendSampler.
	GetBaseURL() string

	// NewHTTPRequest returns a new HTTP request, it can use the given
	// sample ID to generate a new request.
	NewHTTPRequest(ctx context.Context, sampleID uint64) (*http.Request, error)
}

Requestor knows how to construct a new request to the target backend

type ResponseChecker

type ResponseChecker interface {
	// CheckError checks the the given error for any known types
	CheckError(error) error

	// CheckResponse checks the given HTTP Response object and
	// optionally the response body that has been successfully read.
	// If it returns an error, the sample is deemed to have failed.
	// The given http.Response object must not be nil
	// The response body maybe empty depending on the kind of
	// request sent to the server.
	CheckResponse(backend.RequestResponse) error
}

ResponseChecker checks the given HTTP Response object and optionally the response body that has been successfully read. If it returns an error, the sample is deemed to have failed. The given http.Response object must not be nil The response body maybe empty depending on the kind of request sent to the server.

func NewResponseChecker

func NewResponseChecker() ResponseChecker

type ResponseCheckerFunc

type ResponseCheckerFunc func(backend.RequestResponse) error

func (ResponseCheckerFunc) CheckResponse

func (c ResponseCheckerFunc) CheckResponse(rr backend.RequestResponse) error

type SampleCollector

type SampleCollector interface {
	Collect(backend.SampleResult)
}

SampleCollector collects one sample result at a time in the following sequence: 1, 2, 3 ... N. When there are no more samples, an empty SampleResult is provided as a marker to indicate no more results are arriving.

Jump to

Keyboard shortcuts

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