Documentation
¶
Index ¶
- Constants
- func GetOrLaunch(l *Launcher, serverID string) (*mcp.Connection, error)
- func GetOrLaunchForSession(l *Launcher, serverID, sessionID string) (*mcp.Connection, error)
- type ConnectionKey
- type ConnectionMetadata
- type ConnectionState
- type Launcher
- type PoolConfig
- type SessionConnectionPool
- func (p *SessionConnectionPool) Delete(backendID, sessionID string)
- func (p *SessionConnectionPool) Get(backendID, sessionID string) (*mcp.Connection, bool)
- func (p *SessionConnectionPool) GetMetadata(backendID, sessionID string) (*ConnectionMetadata, bool)
- func (p *SessionConnectionPool) List() []ConnectionKey
- func (p *SessionConnectionPool) RecordError(backendID, sessionID string)
- func (p *SessionConnectionPool) Set(backendID, sessionID string, conn *mcp.Connection)
- func (p *SessionConnectionPool) Size() int
- func (p *SessionConnectionPool) Stop()
Constants ¶
const ( DefaultIdleTimeout = 30 * time.Minute DefaultCleanupInterval = 5 * time.Minute DefaultMaxErrorCount = 10 )
Default configuration values
Variables ¶
This section is empty.
Functions ¶
func GetOrLaunch ¶
func GetOrLaunch(l *Launcher, serverID string) (*mcp.Connection, error)
GetOrLaunch returns an existing connection or launches a new one
func GetOrLaunchForSession ¶
func GetOrLaunchForSession(l *Launcher, serverID, sessionID string) (*mcp.Connection, error)
GetOrLaunchForSession returns a session-aware connection or launches a new one This is used for stateful stdio backends that require persistent connections
Types ¶
type ConnectionKey ¶
ConnectionKey uniquely identifies a connection by backend and session
func (ConnectionKey) String ¶
func (k ConnectionKey) String() string
String returns a string representation of the connection key
type ConnectionMetadata ¶
type ConnectionMetadata struct {
Connection *mcp.Connection
CreatedAt time.Time
LastUsedAt time.Time
RequestCount int
ErrorCount int
State ConnectionState
}
ConnectionMetadata tracks information about a pooled connection
type ConnectionState ¶
type ConnectionState string
ConnectionState represents the state of a pooled connection
const ( ConnectionStateActive ConnectionState = "active" ConnectionStateIdle ConnectionState = "idle" ConnectionStateClosed ConnectionState = "closed" )
type Launcher ¶
type Launcher struct {
// contains filtered or unexported fields
}
Launcher manages backend MCP server connections
type PoolConfig ¶
type PoolConfig struct {
IdleTimeout time.Duration
CleanupInterval time.Duration
MaxErrorCount int
}
PoolConfig configures the connection pool
type SessionConnectionPool ¶
type SessionConnectionPool struct {
// contains filtered or unexported fields
}
SessionConnectionPool manages connections keyed by (backend, session)
func NewSessionConnectionPool ¶
func NewSessionConnectionPool(ctx context.Context) *SessionConnectionPool
NewSessionConnectionPool creates a new connection pool with default config
func NewSessionConnectionPoolWithConfig ¶
func NewSessionConnectionPoolWithConfig(ctx context.Context, config PoolConfig) *SessionConnectionPool
NewSessionConnectionPoolWithConfig creates a new connection pool with custom config
func (*SessionConnectionPool) Delete ¶
func (p *SessionConnectionPool) Delete(backendID, sessionID string)
Delete removes a connection from the pool
func (*SessionConnectionPool) Get ¶
func (p *SessionConnectionPool) Get(backendID, sessionID string) (*mcp.Connection, bool)
Get retrieves a connection from the pool
func (*SessionConnectionPool) GetMetadata ¶
func (p *SessionConnectionPool) GetMetadata(backendID, sessionID string) (*ConnectionMetadata, bool)
GetMetadata returns metadata for a connection (for testing/monitoring)
func (*SessionConnectionPool) List ¶
func (p *SessionConnectionPool) List() []ConnectionKey
List returns all connection keys in the pool (for monitoring/debugging)
func (*SessionConnectionPool) RecordError ¶
func (p *SessionConnectionPool) RecordError(backendID, sessionID string)
RecordError increments the error count for a connection
func (*SessionConnectionPool) Set ¶
func (p *SessionConnectionPool) Set(backendID, sessionID string, conn *mcp.Connection)
Set adds or updates a connection in the pool
func (*SessionConnectionPool) Size ¶
func (p *SessionConnectionPool) Size() int
Size returns the number of connections in the pool
func (*SessionConnectionPool) Stop ¶
func (p *SessionConnectionPool) Stop()
Stop gracefully shuts down the connection pool