Documentation ¶
Index ¶
- func NewEndpoint(opts ...HTTPEndpointOption) goload.Endpoint
- func NewHTTPClient(options ...HTTPTransportOption) *http.Client
- type ClientPool
- type EndpointOptions
- type HTTPEndpointOption
- func WithHTTPClient(client *http.Client) HTTPEndpointOption
- func WithHTTPMethod(method string) HTTPEndpointOption
- func WithRequestsPerMinute(rpm int32) HTTPEndpointOption
- func WithTimeout(timeout time.Duration) HTTPEndpointOption
- func WithURL(uri url.URL) HTTPEndpointOption
- func WithURLFunc(endpointName string, getUrl func() url.URL) HTTPEndpointOption
- func WithURLString(uri string) HTTPEndpointOption
- func WithValidateResponse(validate func(res *http.Response) error) HTTPEndpointOption
- type HTTPTransportOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEndpoint ¶
func NewEndpoint(opts ...HTTPEndpointOption) goload.Endpoint
NewEndpoint creates a new HTTP based loadtest endpoint.
To configure it you can use the functional options.
func NewHTTPClient ¶
func NewHTTPClient(options ...HTTPTransportOption) *http.Client
NewHTTPClient creates a new http client for loadtesting.
It allows to specify various request options which will be applied to all requests.
Types ¶
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
type EndpointOptions ¶
type EndpointOptions struct {
// contains filtered or unexported fields
}
func (*EndpointOptions) Name ¶
func (options *EndpointOptions) Name() string
type HTTPEndpointOption ¶
type HTTPEndpointOption func(options *EndpointOptions)
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) HTTPEndpointOption
WithHTTPClient configures a static http client to be used for the loadtest endpoint.
func WithHTTPMethod ¶
func WithHTTPMethod(method string) HTTPEndpointOption
WithHTTPMethod sets the HTTP method used for the requests.
By default, the `Endpoint` will use an `GET` request.
func WithRequestsPerMinute ¶
func WithRequestsPerMinute(rpm int32) HTTPEndpointOption
WithRequestsPerMinute configures the targeted requests per minute compared to other endpoints.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) HTTPEndpointOption
WithTimeout configures a specific timeout duration for the endpoint overriding the global config.
func WithURL ¶
func WithURL(uri url.URL) HTTPEndpointOption
WithURL allows setting a static URL for the loadtest endpoint.
func WithURLFunc ¶
func WithURLFunc(endpointName string, getUrl func() url.URL) HTTPEndpointOption
WithURLFunc allows for a dynamic creation of the URL per request made in the loadtest.
An explicit endpoint name needs to be provided here for reporting purposes as an identifier.
func WithURLString ¶
func WithURLString(uri string) HTTPEndpointOption
WithURLString allows setting a static string URL for the loadtest endpoint.
func WithValidateResponse ¶
func WithValidateResponse(validate func(res *http.Response) error) HTTPEndpointOption
WithValidateResponse allows to configure a custom check if the request should be counted as successful or not.
By default, the request is successful if it returns a 2xx status code.
type HTTPTransportOption ¶
func WithBasicAuth ¶
func WithBasicAuth(username string, password string) HTTPTransportOption
WithBasicAuth sets basic auth credentials on each request.
func WithHeader ¶
func WithHeader(key string, value string) HTTPTransportOption
WithHeader sets a custom header on each request.
func WithUserAgent ¶
func WithUserAgent(userAgent string) HTTPTransportOption
WithUserAgent sets the user agent on each of the request for the client pool.