Documentation
¶
Overview ¶
Package pool provides stdio MCP server subprocess pooling and management. It handles concurrent request processing, health monitoring, and lifecycle management for multiple stdio-based MCP servers.
Index ¶
- Constants
- type HealthCheckResult
- type HealthChecker
- func (hc *HealthChecker) CheckServer(ctx context.Context, name string) HealthCheckResult
- func (hc *HealthChecker) GetAllHealth() map[string]HealthCheckResult
- func (hc *HealthChecker) GetServerHealth(name string) (HealthStatus, error)
- func (hc *HealthChecker) RegisterServer(name string)
- func (hc *HealthChecker) Start(ctx context.Context, interval time.Duration)
- func (hc *HealthChecker) Stop()
- func (hc *HealthChecker) UnregisterServer(name string)
- type HealthStatus
- type JSONRPCError
- type PingRequest
- type PingResponse
- type PoolQueueManager
- func (qm *PoolQueueManager) GetOrCreateQueue(name string, maxConcurrent int, queueTimeout time.Duration) *ServerQueue
- func (qm *PoolQueueManager) GetQueueStats(name string) (active int, pending int, atCapacity bool)
- func (qm *PoolQueueManager) ListQueues() []string
- func (qm *PoolQueueManager) RemoveQueue(name string)
- type Request
- type RequestQueue
- type Response
- type ServerHandle
- type ServerQueue
- type ServerState
- type ServerStats
- type StdioPool
- func (p *StdioPool) Close() error
- func (p *StdioPool) GetServer(name string) (*StdioServerV2, error)
- func (p *StdioPool) GetServerState(name string) (ServerState, error)
- func (p *StdioPool) GetServerStats(name string) (ServerStats, error)
- func (p *StdioPool) ListServers() []string
- func (p *StdioPool) PutRequest(name string, req Request) error
- func (p *StdioPool) RestartServer(ctx context.Context, name string) error
- func (p *StdioPool) SendRequest(ctx context.Context, serverName string, req *proxy.JSONRPCRequest, ...) (*proxy.JSONRPCResponse, error)
- func (p *StdioPool) ServerCount() int
- func (p *StdioPool) StartAllServers(ctx context.Context, configs []*migrate.ServerConfig) error
- func (p *StdioPool) StartServer(ctx context.Context, config *migrate.ServerConfig) error
- func (p *StdioPool) StopServer(name string) error
- type StdioServerConfig
- type StdioServerV2
Constants ¶
View Source
const ( ErrCodeInternalError = -32603 ErrCodeServerError = -32000 ErrCodeTimeout = -32001 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthCheckResult ¶
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
func NewHealthChecker ¶
func NewHealthChecker(pool *StdioPool, logger *slog.Logger) *HealthChecker
func (*HealthChecker) CheckServer ¶
func (hc *HealthChecker) CheckServer(ctx context.Context, name string) HealthCheckResult
func (*HealthChecker) GetAllHealth ¶
func (hc *HealthChecker) GetAllHealth() map[string]HealthCheckResult
func (*HealthChecker) GetServerHealth ¶
func (hc *HealthChecker) GetServerHealth(name string) (HealthStatus, error)
func (*HealthChecker) RegisterServer ¶
func (hc *HealthChecker) RegisterServer(name string)
func (*HealthChecker) Start ¶
func (hc *HealthChecker) Start(ctx context.Context, interval time.Duration)
func (*HealthChecker) Stop ¶
func (hc *HealthChecker) Stop()
func (*HealthChecker) UnregisterServer ¶
func (hc *HealthChecker) UnregisterServer(name string)
type HealthStatus ¶
type HealthStatus string
const ( HealthUnknown HealthStatus = "unknown" HealthHealthy HealthStatus = "healthy" HealthDegraded HealthStatus = "degraded" HealthUnhealthy HealthStatus = "unhealthy" HealthError HealthStatus = "error" )
type JSONRPCError ¶
type JSONRPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
func (*JSONRPCError) Error ¶
func (e *JSONRPCError) Error() string
type PingRequest ¶
type PingResponse ¶
type PingResponse struct {
ID interface{} `json:"id"`
JSONRPC string `json:"jsonrpc"`
Result json.RawMessage `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
type PoolQueueManager ¶
type PoolQueueManager struct {
// contains filtered or unexported fields
}
func NewPoolQueueManager ¶
func NewPoolQueueManager(logger *slog.Logger) *PoolQueueManager
func (*PoolQueueManager) GetOrCreateQueue ¶
func (qm *PoolQueueManager) GetOrCreateQueue(name string, maxConcurrent int, queueTimeout time.Duration) *ServerQueue
func (*PoolQueueManager) GetQueueStats ¶
func (qm *PoolQueueManager) GetQueueStats(name string) (active int, pending int, atCapacity bool)
func (*PoolQueueManager) ListQueues ¶
func (qm *PoolQueueManager) ListQueues() []string
func (*PoolQueueManager) RemoveQueue ¶
func (qm *PoolQueueManager) RemoveQueue(name string)
type RequestQueue ¶
type RequestQueue struct {
// contains filtered or unexported fields
}
func NewRequestQueue ¶
func (*RequestQueue) Enqueue ¶
func (q *RequestQueue) Enqueue(req Request) bool
func (*RequestQueue) IsEmpty ¶
func (q *RequestQueue) IsEmpty() bool
func (*RequestQueue) IsFull ¶
func (q *RequestQueue) IsFull() bool
func (*RequestQueue) Size ¶
func (q *RequestQueue) Size() int
type Response ¶
type Response struct {
Result json.RawMessage `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
ID interface{} `json:"id"`
}
type ServerHandle ¶
type ServerHandle struct {
Name string
State ServerState
Stats ServerStats
}
type ServerQueue ¶
type ServerQueue struct {
// contains filtered or unexported fields
}
func NewServerQueue ¶
func (*ServerQueue) Enqueue ¶
func (sq *ServerQueue) Enqueue(req Request) bool
func (*ServerQueue) IsAtCapacity ¶
func (sq *ServerQueue) IsAtCapacity() bool
func (*ServerQueue) PendingCount ¶
func (sq *ServerQueue) PendingCount() int
func (*ServerQueue) Release ¶
func (sq *ServerQueue) Release()
type ServerState ¶
type ServerState string
const ( StateIdle ServerState = "idle" StateRunning ServerState = "running" StateBusy ServerState = "busy" StateStopping ServerState = "stopping" StateStopped ServerState = "stopped" StateStarting ServerState = "starting" StateError ServerState = "error" )
type ServerStats ¶
type StdioPool ¶
type StdioPool struct {
// contains filtered or unexported fields
}
func NewStdioPool ¶
func (*StdioPool) GetServerState ¶
func (p *StdioPool) GetServerState(name string) (ServerState, error)
func (*StdioPool) GetServerStats ¶
func (p *StdioPool) GetServerStats(name string) (ServerStats, error)
func (*StdioPool) ListServers ¶
func (*StdioPool) RestartServer ¶
func (*StdioPool) SendRequest ¶
func (*StdioPool) ServerCount ¶
func (*StdioPool) StartAllServers ¶
func (*StdioPool) StartServer ¶
func (*StdioPool) StopServer ¶
type StdioServerConfig ¶
type StdioServerV2 ¶
type StdioServerV2 struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.