Documentation
¶
Overview ¶
Package clientpool provides a shared HTTP client pool keyed by base URL This enables HTTP/2 connection sharing across providers targeting the same base URL
Index ¶
- func Clear()
- func GetClient(baseURL string) *pkghttp.HTTPClient
- func GetClientWithConfig(baseURL string, config pkghttp.HTTPClientConfig) *pkghttp.HTTPClient
- func GetClientWithTimeout(baseURL string, timeout time.Duration) *pkghttp.HTTPClient
- func GetUnderlyingClient(baseURL string) *http.Client
- func RemoveClient(baseURL string)
- func Size() int
- type ClientPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clear ¶
func Clear()
Clear removes all cached clients from the pool This is primarily useful for testing or when you need to reset connection state
func GetClient ¶
func GetClient(baseURL string) *pkghttp.HTTPClient
GetClient returns an HTTP client for the given base URL, creating if needed This ensures that providers targeting the same base URL share the same HTTP client, enabling HTTP/2 connection pooling and reducing resource usage
func GetClientWithConfig ¶
func GetClientWithConfig(baseURL string, config pkghttp.HTTPClientConfig) *pkghttp.HTTPClient
GetClientWithConfig returns an HTTP client for the given base URL with custom config, creating if needed. If a client already exists for the base URL, it will be returned and the custom config will not be applied (first caller wins)
func GetClientWithTimeout ¶
func GetClientWithTimeout(baseURL string, timeout time.Duration) *pkghttp.HTTPClient
GetClientWithTimeout returns an HTTP client for the given base URL with a specific timeout If a client already exists for the base URL, it will be returned regardless of timeout
func GetUnderlyingClient ¶
GetUnderlyingClient returns the underlying http.Client from a pooled HTTPClient This is provided for compatibility with code that needs the standard library client
func RemoveClient ¶
func RemoveClient(baseURL string)
RemoveClient removes a specific client from the pool
Types ¶
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
ClientPool manages shared HTTP clients keyed by base URL This enables HTTP/2 connection sharing across providers targeting the same base URL