Documentation ¶
Index ¶
- func NewSmasher(options ...SmasherOption) *smasher
- type BuildRequestFunc
- type HttpClient
- type SmasherOption
- func WithAnonymizeRequests(anonymize bool) SmasherOption
- func WithClient(c HttpClient) SmasherOption
- func WithErrorFunc(f func(err error)) SmasherOption
- func WithIterations(i int) SmasherOption
- func WithSequenceFunc(f sequence.SequenceFunc) SmasherOption
- func WithStartIndex(i int) SmasherOption
- func WithSuccessResponseCallback(f SuccessResponseCallback) SmasherOption
- func WithWorkerCount(c int) SmasherOption
- type SuccessResponse
- type SuccessResponseCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSmasher ¶
func NewSmasher(options ...SmasherOption) *smasher
NewSmasher returns a new smasher with the specified configuration
Types ¶
type BuildRequestFunc ¶
BuildRequestFunc is a function which accepts a iteration item and returns an http request
type HttpClient ¶ added in v1.0.0
type SmasherOption ¶
type SmasherOption func(s *smasher)
SmasherOption is a functional option for overriding the default configuration
func WithAnonymizeRequests ¶
func WithAnonymizeRequests(anonymize bool) SmasherOption
WithAnonymizeRequests overrides the default flag to indicate whether reqeusts should be anonymized (by adding additional headers)
func WithClient ¶
func WithClient(c HttpClient) SmasherOption
WithClient allows you to override the default http client, for example if you want to add your own round-tripper or timeouts
func WithErrorFunc ¶
func WithErrorFunc(f func(err error)) SmasherOption
WithErrorFunc overrides the default error callback, which simply logs the error to stdout. This function is called in case of an error while performing the request (not in case of an error response)
func WithIterations ¶
func WithIterations(i int) SmasherOption
WithIterations sets the number of calls the smasher should make (default is 1)
func WithSequenceFunc ¶
func WithSequenceFunc(f sequence.SequenceFunc) SmasherOption
func WithStartIndex ¶
func WithStartIndex(i int) SmasherOption
WithStartIndex overrides the default start index for each iteration in case, for example, you want to resume from a previous position
func WithSuccessResponseCallback ¶
func WithSuccessResponseCallback(f SuccessResponseCallback) SmasherOption
WithSuccessResponseCallback overrides the default success callback which handles all http responses. The default simply logs the response body
func WithWorkerCount ¶
func WithWorkerCount(c int) SmasherOption
WithWorkerCount overrides the default worker count (default is 1, so a single thread)
type SuccessResponse ¶
type SuccessResponse struct { StatusCode int RequestBody []byte ResponseBody []byte RawRequest *nethttp.Request RawResponse *nethttp.Response }
SuccessResponse is sent to the success callback. This response contains the original request as well as the response.
type SuccessResponseCallback ¶
type SuccessResponseCallback func(resp SuccessResponse)
SuccessResponseCallback is a callback function which is called after a successful http request is performed