Documentation
¶
Index ¶
- type FastRequest
- type PerformanceConfig
- type Response
- type ZeroAllocDriver
- func (d *ZeroAllocDriver) Do(req httpclient.Request) (httpclient.Response, error)
- func (d *ZeroAllocDriver) FormRequest(method, url string, formData url.Values) (httpclient.Request, error)
- func (d *ZeroAllocDriver) GetBuffer() *bytes.Buffer
- func (d *ZeroAllocDriver) JSONRequest(method, url string, jsonBytes []byte) (httpclient.Request, error)
- func (d *ZeroAllocDriver) PutBuffer(buf *bytes.Buffer)
- func (d *ZeroAllocDriver) Request(method, url string, body io.Reader) (httpclient.Request, error)
- func (d *ZeroAllocDriver) StringRequest(method, url, body string) (httpclient.Request, error)
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) 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 ¶
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 ¶
Body returns the body of the HTTP response as an io.Reader. If the response is nil, it returns nil.
func (*Response) Close ¶
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 ¶
StatusCode returns the HTTP status code of the response. If the response is nil, it returns 0.
type ZeroAllocDriver ¶
ZeroAllocDriver is a driver optimized for zero allocations in hot paths.
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 ¶
func (d *ZeroAllocDriver) Do(req httpclient.Request) (httpclient.Response, error)
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.