feat: add test connection manager

This commit is contained in:
2026-05-20 21:55:43 +03:00
parent f0c3a67826
commit 4f4d213aca
4 changed files with 238 additions and 105 deletions
@@ -21,11 +21,11 @@ func NewConnectionManager(heartbeat heartbeatStore, status statusNotifier, logge
return &ConnectionManager{heartbeat: heartbeat, log: logger, status: status, agentConnStore: NewAgentConnStore()}
}
func (c *ConnectionManager) NewConnection(stream streamConn) {
func (c *ConnectionManager) NewConnection(stream streamConn) error {
AgentID, err := agentIDFromMetadata(stream.Context())
if err != nil {
c.log.Error().Err(err).Msg("missing agent id in metadata")
return
return fmt.Errorf("get agent id: %w", err)
}
c.log.Info().Str("agentID", AgentID).Msg("connection accepted")
@@ -41,6 +41,8 @@ func (c *ConnectionManager) NewConnection(stream streamConn) {
}
c.agentConnStore.Delete(AgentID)
}()
return nil
}
func (c *ConnectionManager) GetConnection(AgentID string) (*AgentConnection, error) {