Documentation
¶
Overview ¶
Package manager provides the ConnectionManager implementation.
Index ¶
- type ConnectionManager
- func (cm *ConnectionManager) ConnectWithRetry(remote config.RemoteMCPServer)
- func (cm *ConnectionManager) GetConnectionState(url string) models.ConnectionState
- func (cm *ConnectionManager) GetToolHandlers() map[string]*tools.RemoteToolInfo
- func (cm *ConnectionManager) HandleServerAdded(event events.Event)
- func (cm *ConnectionManager) HandleServerRemoved(event events.Event)
- func (cm *ConnectionManager) HandleToolsProcessed(event events.Event)
- func (cm *ConnectionManager) RefreshMCPServerTools()
- func (cm *ConnectionManager) SetConnectionState(url string, state models.ConnectionState)
- func (cm *ConnectionManager) Start()
- func (cm *ConnectionManager) Stop()
- func (cm *ConnectionManager) UpdateServerTools(serverURL string, fetchedTools interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager handles the lifecycle of remote MCP connections. It maintains two types of state:
1. Runtime State (in memory):
- Active connections to remote servers
- Currently available tools and their handlers
- Connection health states
2. Persistent State (in database through events):
- Configured server list
- Tool registrations
- Server health status
func New ¶
func New( cfg config.ServerConfig, logger log.Logger, eventBus events.Bus, mcpServer *server.MCPServer, connectionsTotal *prometheus.GaugeVec, toolsTotal *prometheus.GaugeVec, toolSyncLatency *prometheus.HistogramVec, ) *ConnectionManager
New creates a new ConnectionManager instance
func (*ConnectionManager) ConnectWithRetry ¶
func (cm *ConnectionManager) ConnectWithRetry(remote config.RemoteMCPServer)
ConnectWithRetry attempts to connect to a remote server with exponential backoff
func (*ConnectionManager) GetConnectionState ¶
func (cm *ConnectionManager) GetConnectionState(url string) models.ConnectionState
GetConnectionState gets the current state of a connection
func (*ConnectionManager) GetToolHandlers ¶
func (cm *ConnectionManager) GetToolHandlers() map[string]*tools.RemoteToolInfo
GetToolHandlers returns the tool handlers map (used by function closures)
func (*ConnectionManager) HandleServerAdded ¶
func (cm *ConnectionManager) HandleServerAdded(event events.Event)
HandleServerAdded handles the ServerAdded event
func (*ConnectionManager) HandleServerRemoved ¶
func (cm *ConnectionManager) HandleServerRemoved(event events.Event)
HandleServerRemoved handles the ServerRemoved event
func (*ConnectionManager) HandleToolsProcessed ¶
func (cm *ConnectionManager) HandleToolsProcessed(event events.Event)
HandleToolsProcessed handles the ToolsProcessedInDB event
func (*ConnectionManager) RefreshMCPServerTools ¶
func (cm *ConnectionManager) RefreshMCPServerTools()
RefreshMCPServerTools rebuilds the runtime tool state. IMPORTANT: This function assumes the caller holds the cm.mu lock.
func (*ConnectionManager) SetConnectionState ¶
func (cm *ConnectionManager) SetConnectionState(url string, state models.ConnectionState)
SetConnectionState updates both runtime and persistent connection state
func (*ConnectionManager) Start ¶
func (cm *ConnectionManager) Start()
Start begins managing connections and health checks
func (*ConnectionManager) Stop ¶
func (cm *ConnectionManager) Stop()
Stop gracefully shuts down all connections
func (*ConnectionManager) UpdateServerTools ¶
func (cm *ConnectionManager) UpdateServerTools(serverURL string, fetchedTools interface{})
UpdateServerTools synchronizes tool state between runtime and persistent storage