stdhttpzeroclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FastRequest

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

FastRequest is a zero-allocation request implementation for high-performance scenarios.

func NewFastRequest

func NewFastRequest(method, urlStr string, body io.Reader) *FastRequest

NewFastRequest creates a new FastRequest with minimal allocations.

func (*FastRequest) Reset

func (r *FastRequest) Reset()

Reset resets the request for reuse.

func (*FastRequest) SetContentType

func (r *FastRequest) SetContentType(contentType string)

SetContentType sets the Content-Type header for the request.

func (*FastRequest) SetHeader

func (r *FastRequest) SetHeader(key, value string)

SetHeader sets a header for the request.

func (*FastRequest) ToHTTPRequest

func (r *FastRequest) ToHTTPRequest() (*http.Request, error)

ToHTTPRequest converts FastRequest to http.Request.

type PerformanceConfig

type PerformanceConfig = stdhttpclient.PerformanceConfig

PerformanceConfig is an alias for stdhttpclient.PerformanceConfig.

func DefaultPerformanceConfig

func DefaultPerformanceConfig() PerformanceConfig

DefaultPerformanceConfig returns default high-performance configuration.

func ExtremePerformanceConfig

func ExtremePerformanceConfig() PerformanceConfig

ExtremePerformanceConfig returns configuration optimized for maximum throughput. Use this configuration when you need to send thousands of requests per second.

type Response

type Response struct {
	HTTP *http.Response
	// contains filtered or unexported fields
}

Response is a high-performance wrapper around http.Response that implements the httpclient.Response interface. It provides methods to access the response status code, body, and to close the response body. The response uses object pooling to minimize allocations.

func (*Response) Body

func (r *Response) Body() io.Reader

Body returns the body of the HTTP response as an io.Reader. If the response is nil, it returns nil.

func (*Response) Close

func (r *Response) Close() error

Close closes the response body and returns objects to the pool for reuse. This method should always be called when the response is no longer needed to prevent memory leaks and to return pooled objects for reuse.

func (*Response) StatusCode

func (r *Response) StatusCode() int

StatusCode returns the HTTP status code of the response. If the response is nil, it returns 0.

type ZeroAllocDriver

type ZeroAllocDriver struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

ZeroAllocDriver is a driver optimized for zero allocations in hot paths.

func NewDriver

func NewDriver() *ZeroAllocDriver

NewDriver creates a new zero-allocation driver.

func NewDriverWithConfig

func NewDriverWithConfig(config PerformanceConfig) *ZeroAllocDriver

NewDriverWithConfig creates a new Driver with custom performance configuration.

func NewDriverWithHTTPClient

func NewDriverWithHTTPClient(client *http.Client) *ZeroAllocDriver

NewDriverWithHTTPClient creates a new Driver with the specified HTTP client. This allows for custom HTTP client configurations, such as timeouts or transport settings. The driver is initialized with object pools for optimal performance.

func NewExtremePerformanceDriver

func NewExtremePerformanceDriver() *ZeroAllocDriver

NewExtremePerformanceDriver creates a driver optimized for extreme throughput.

func (*ZeroAllocDriver) Do

Do executes the request.

func (*ZeroAllocDriver) FormRequest

func (d *ZeroAllocDriver) FormRequest(method, url string, formData url.Values) (httpclient.Request, error)

FormRequest creates a request with form data using pooled buffer.

func (*ZeroAllocDriver) GetBuffer

func (d *ZeroAllocDriver) GetBuffer() *bytes.Buffer

GetBuffer gets a buffer from the pool.

func (*ZeroAllocDriver) JSONRequest

func (d *ZeroAllocDriver) JSONRequest(method, url string, jsonBytes []byte) (httpclient.Request, error)

JSONRequest creates a request with JSON body using pooled buffer.

func (*ZeroAllocDriver) PutBuffer

func (d *ZeroAllocDriver) PutBuffer(buf *bytes.Buffer)

PutBuffer returns a buffer to the pool.

func (*ZeroAllocDriver) Request

func (d *ZeroAllocDriver) Request(method, url string, body io.Reader) (httpclient.Request, error)

Request creates a new request with minimal allocations.

func (*ZeroAllocDriver) StringRequest

func (d *ZeroAllocDriver) StringRequest(method, url, body string) (httpclient.Request, error)

StringRequest creates a request with string body using pooled buffer.

Jump to

Keyboard shortcuts

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