connpool

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConnection

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

func (*ClientConnection) GetClient

func (c *ClientConnection) GetClient() *client.Client

func (*ClientConnection) IsHealthy

func (c *ClientConnection) IsHealthy() bool

func (*ClientConnection) SetHealthy

func (c *ClientConnection) SetHealthy(healthy bool)

type ConnectionPool

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

func NewConnectionPool

func NewConnectionPool(config PoolConfig, logger *slog.Logger) *ConnectionPool

func (*ConnectionPool) Close

func (cp *ConnectionPool) Close() error

func (*ConnectionPool) GetAllMetrics

func (cp *ConnectionPool) GetAllMetrics() map[string]PoolMetrics

func (*ConnectionPool) GetClient

func (cp *ConnectionPool) GetClient(ctx context.Context, serverName string) (*ClientConnection, error)

func (*ConnectionPool) GetMetrics

func (cp *ConnectionPool) GetMetrics(serverName string) (PoolMetrics, error)

func (*ConnectionPool) HasServer

func (cp *ConnectionPool) HasServer(name string) bool

func (*ConnectionPool) ListServers

func (cp *ConnectionPool) ListServers() []string

func (*ConnectionPool) ListTools

func (cp *ConnectionPool) ListTools(ctx context.Context, serverName string) ([]mcp.Tool, error)

func (*ConnectionPool) RegisterServer

func (cp *ConnectionPool) RegisterServer(name string, cfg *migrate.ServerConfig)

func (*ConnectionPool) ReturnClient

func (cp *ConnectionPool) ReturnClient(serverName string, conn *ClientConnection)

func (*ConnectionPool) SendToolRequest

func (cp *ConnectionPool) SendToolRequest(ctx context.Context, serverName string, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error)

func (*ConnectionPool) UnregisterServer

func (cp *ConnectionPool) UnregisterServer(name string)

type PoolConfig

type PoolConfig struct {
	MaxSize     int           `yaml:"max_size"`
	MaxWaitTime time.Duration `yaml:"max_wait_time"`
	IdleTimeout time.Duration `yaml:"idle_timeout"`
	HealthCheck time.Duration `yaml:"health_check_interval"`
	InitialSize int           `yaml:"initial_size"`
}

func DefaultPoolConfig

func DefaultPoolConfig() PoolConfig

type PoolMetrics

type PoolMetrics struct {
	TotalRequests    int64
	ActiveClients    int64
	AvailableClients int64
	WaitingClients   int64
	Timeouts         int64
	Errors           int64
	AvgLatencyMs     float64
}

type Response

type Response struct {
	Result json.RawMessage `json:"result,omitempty"`
	ID     interface{}     `json:"id"`
}

type ServerPool

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

func NewServerPool

func NewServerPool(maxSize int, config PoolConfig, logger *slog.Logger) *ServerPool

func (*ServerPool) Close

func (sp *ServerPool) Close() error

func (*ServerPool) GetClient

func (sp *ServerPool) GetClient(ctx context.Context, createFunc func() (*client.Client, error)) (*ClientConnection, error)

func (*ServerPool) GetMetrics

func (sp *ServerPool) GetMetrics() PoolMetrics

func (*ServerPool) ReturnClient

func (sp *ServerPool) ReturnClient(conn *ClientConnection)

Jump to

Keyboard shortcuts

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