requests

package
v0.5.502 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientGeneratorFunc added in v0.5.0

type ClientGeneratorFunc func() *fasthttp.HostClient

type Request added in v0.5.0

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

Request represents an HTTP request to be sent using the fasthttp client. It isn't thread-safe and should be used by a single goroutine.

func (*Request) Send added in v0.5.0

func (r *Request) Send(ctx context.Context, timeout time.Duration) (*fasthttp.Response, error)

Send sends the HTTP request using the fasthttp client with a specified timeout. It returns the HTTP response or an error if the request fails or times out.

type RequestGeneratorFunc added in v0.5.0

type RequestGeneratorFunc func() *fasthttp.Request

type Response

type Response struct {
	Response string
	Time     time.Duration
}

type Responses

type Responses []*Response

func Run

func Run(ctx context.Context, requestConfig *config.RequestConfig) (Responses, error)

Run executes the main logic for processing requests based on the provided configuration. It first checks for an internet connection with a timeout context. If no connection is found, it returns an error. Then, it initializes clients based on the request configuration and releases the dodos. If the context is canceled and no responses are collected, it returns an interrupt error.

Parameters:

  • ctx: The context for managing request lifecycle and cancellation.
  • requestConfig: The configuration for the request, including timeout, proxies, and other settings.

Returns:

  • Responses: A collection of responses from the executed requests.
  • error: An error if the operation fails, such as no internet connection or an interrupt.

func (Responses) Print

func (responses Responses) Print()

Print prints the responses in a tabular format, including information such as response count, minimum time, maximum time, average time, and latency percentiles.

Jump to

Keyboard shortcuts

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