Documentation ¶
Index ¶
- func NewClient(options ...HTTPTransportOption) *http.Client
- func NewEndpoint(opts ...HTTPEndpointOption) goload.Endpoint
- func SetHTTPClient(client *http.Client)
- type EndpointOptions
- type HTTPEndpointOption
- func WithHTTPClient(client *http.Client) HTTPEndpointOption
- func WithHTTPMethod(method string) HTTPEndpointOption
- func WithHeader(key string, value string) HTTPEndpointOption
- func WithName(name 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 NewClient ¶
func NewClient(options ...HTTPTransportOption) *http.Client
NewClient creates a new http client for loadtesting with custom options.
It allows to specify various request options which will be applied to all requests.
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 SetHTTPClient ¶
Types ¶
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 defaultClient 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 WithHeader ¶
func WithHeader(key string, value string) HTTPEndpointOption
func WithName ¶
func WithName(name string) HTTPEndpointOption
WithName allows manually setting the endpoint name
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 WithClientBasicAuth ¶
func WithClientBasicAuth(username string, password string) HTTPTransportOption
WithClientBasicAuth sets basic auth credentials on each request.
func WithClientHeader ¶
func WithClientHeader(key string, value string) HTTPTransportOption
WithClientHeader sets a custom header on each request.
func WithClientUserAgent ¶
func WithClientUserAgent(userAgent string) HTTPTransportOption
WithClientUserAgent sets the user agent on each of the request