pool

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetPool

func SetPool(pool HTTPPool)

SetPool sets the global pool for mcp clients This allows external pools to be injected

func SetPoolConfig

func SetPoolConfig(config *PoolConfig)

SetPoolConfig sets the configuration for the mcp package's default pool Must be called before any HTTP calls are made (before GetPool)

Types

type DefaultPool

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

DefaultPool is the default HTTP pool implementation

func (*DefaultPool) GetHTTPClient

func (p *DefaultPool) GetHTTPClient() *http.Client

GetHTTPClient returns the shared HTTP client

type HTTPPool

type HTTPPool interface {
	GetHTTPClient() *http.Client
}

HTTPPool interface for HTTP client providers Implementations can provide connection pooling, custom timeouts, etc.

func GetPool

func GetPool() HTTPPool

GetPool returns the global pool (creates default if nil)

func NewPool added in v0.9.5

func NewPool(config *PoolConfig) HTTPPool

NewPool creates a new HTTP pool with the given configuration. The config is merged with DefaultPoolConfig() - any nil/zero values in config will use the corresponding defaults. This ensures consistency across pools while allowing specific overrides (e.g., InsecureSkipVerify).

Example:

// Create an insecure pool for internal services with self-signed certs
// All other settings (timeouts, connection limits) inherit from defaults
insecurePool := pool.NewPool(&pool.PoolConfig{
    InsecureSkipVerify: true,
})

type PoolConfig

type PoolConfig struct {
	// InsecureSkipVerify allows self-signed certificates
	// WARNING: This should be false in production for security
	InsecureSkipVerify bool

	// Connection pool settings
	MaxIdleConns        int
	MaxIdleConnsPerHost int
	IdleConnTimeout     time.Duration

	// Default timeout for requests
	Timeout time.Duration
}

PoolConfig holds configuration for the default pool in the mcp package

func DefaultPoolConfig

func DefaultPoolConfig() *PoolConfig

DefaultPoolConfig returns sensible defaults (secure by default) Optimized for long-lived AI/MCP connections

func GetPoolConfig

func GetPoolConfig() PoolConfig

GetPoolConfig returns the current pool configuration Returns a copy to prevent external modification of internal state

Jump to

Keyboard shortcuts

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