clientpool

package
v1.0.66 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 4 Imported by: 0

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

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

func GetUnderlyingClient(baseURL string) *http.Client

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

func Size

func Size() int

Size returns the number of clients in 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

Jump to

Keyboard shortcuts

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