Help us shape the future of Go! Take the 2026 Go Developer Survey

launcher

package
v0.0.105 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

type ConnectionKey struct {
	BackendID string
	SessionID string
}

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

func New

func New(ctx context.Context, cfg *config.Config) *Launcher

New creates a new Launcher

func (*Launcher) Close

func (l *Launcher) Close()

Close closes all connections

func (*Launcher) ServerIDs

func (l *Launcher) ServerIDs() []string

ServerIDs returns all configured server IDs

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

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

Jump to

Keyboard shortcuts

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