pool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth contains basic authentication credentials

type BufferPool

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

BufferPool manages reusable byte buffers for response body reading

func (*BufferPool) Get

func (p *BufferPool) Get() []byte

Get retrieves a buffer from the pool

func (*BufferPool) Put

func (p *BufferPool) Put(buf []byte)

Put returns a buffer to the pool

type PooledRequest

type PooledRequest struct {
	Method      string
	URL         string
	Headers     map[string]string
	QueryParams map[string]any
	Body        any
	Timeout     int64 // Use int64 for better performance
	MaxRetries  int
	Context     interface{} // context.Context

	// Authentication
	BasicAuth   *BasicAuth
	BearerToken string
}

PooledRequest represents a reusable request object

func (*PooledRequest) Reset

func (r *PooledRequest) Reset()

Reset clears the request object for reuse

type PooledResponse

type PooledResponse struct {
	StatusCode    int
	Status        string
	Headers       map[string][]string
	Body          string
	RawBody       []byte
	ContentLength int64
	Proto         string
	Duration      int64 // nanoseconds for better performance
	Attempts      int
	Request       interface{} // *http.Request
	Response      interface{} // *http.Response
}

PooledResponse represents a reusable response object

func (*PooledResponse) Reset

func (r *PooledResponse) Reset()

Reset clears the response object for reuse

type RequestPool

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

RequestPool manages reusable request objects to reduce allocations

func (*RequestPool) Get

func (p *RequestPool) Get() *PooledRequest

Get retrieves a request object from the pool

func (*RequestPool) Put

func (p *RequestPool) Put(req *PooledRequest)

Put returns a request object to the pool after resetting it

type ResponsePool

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

ResponsePool manages reusable response objects

func (*ResponsePool) Get

func (p *ResponsePool) Get() *PooledResponse

Get retrieves a response object from the pool

func (*ResponsePool) Put

func (p *ResponsePool) Put(resp *PooledResponse)

Put returns a response object to the pool after resetting it

type StringBuilderPool

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

StringBuilderPool manages reusable string builders for efficient string operations

func (*StringBuilderPool) Get

func (p *StringBuilderPool) Get() *strings.Builder

Get retrieves a string builder from the pool

func (*StringBuilderPool) Put

func (p *StringBuilderPool) Put(sb *strings.Builder)

Put returns a string builder to the pool after resetting it

Jump to

Keyboard shortcuts

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