hit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: CC-BY-SA-4.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Concurrency is the number of concurrent requests to send.
	// Default: 1
	Concurrency int

	// RPS is the requests to send per second.
	// Default: 0 (no rate limiting)
	RPS int

	// Send processes requests.
	// Default: Uses [Send].
	Send SendFunc
}

Options defines the options for sending requests. Uses default options for unset options.

func Defaults

func Defaults() Options

Defaults returns the default Options.

type Result

type Result struct {
	Status   int           // Status is the HTTP status code
	Bytes    int64         // Bytes is the number of bytes transferred
	Duration time.Duration // Duration is the time to complete a request
	Error    error         // Error received after sending a request
}

Result is performance metrics of a single http.Request.

func Send

func Send(client *http.Client, req *http.Request) Result

Send sends an HTTP request and returns a performance Result.

type Results

type Results iter.Seq[Result]

Results is an iterator for Result values.

func SendN

func SendN(ctx context.Context, n int, req *http.Request, opts Options) (Results, error)

SendN sends N requests using Send. It returns a single-use Results iterator that pushes a Result for each http.Request sent.

type SendFunc

type SendFunc func(*http.Request) Result

SendFunc is a type of function that sends an http.Request and returns a Result.

type Summary

type Summary struct {
	Started  time.Time     // Started is the time when requests began
	Requests int           // Requests is the total number of requests made
	Errors   int           // Errors is the total number of failed requests
	Bytes    int64         // Bytes is the total number of bytes transferred
	RPS      float64       // RPS is the number of requests sent per second
	Duration time.Duration // Duration is the total time taken by requests
	Fastest  time.Duration // Fastest is the fastest request duration
	Slowest  time.Duration // Slowest is the slowest request duration
	Success  float64       // Success is the ratio of successful requests
}

Summary is the summary of Result values.

func Summarize

func Summarize(results Results) Summary

Summarize returns a Summary of Results.

Directories

Path Synopsis
cmd
hit command

Jump to

Keyboard shortcuts

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