feat: add connection manager

This commit is contained in:
2026-05-17 12:37:51 +03:00
parent 5b297d5c1f
commit bef8409b8c
10 changed files with 181 additions and 107 deletions
@@ -15,13 +15,13 @@ import (
)
type streamMock struct {
recvCh chan *pb.AgentEvent
sendCh chan *pb.ServerCommandRequest
closeCh chan struct{}
ctx context.Context
mu sync.Mutex
sendErr error
recvErr error
recvCh chan *pb.AgentEvent
sendCh chan *pb.ServerCommandRequest
closeCh chan struct{}
ctx context.Context
mu sync.Mutex
sendErr error
recvErr error
closeOnce sync.Once
}
@@ -260,7 +260,7 @@ func TestAgentConnection_HeartbeatTimeout(t *testing.T) {
Args: nil,
TimeOut: 0,
})
assert.ErrorIs(t, err, ConnectionCloseErr)
assert.ErrorIs(t, err, ErrConnectionClose)
wg.Done()
}()
@@ -286,7 +286,7 @@ func TestAgentConnection_ConnectionClose(t *testing.T) {
Args: nil,
TimeOut: 0,
})
assert.ErrorIs(t, err, ConnectionCloseErr)
assert.ErrorIs(t, err, ErrConnectionClose)
wg.Done()
}()
@@ -365,7 +365,7 @@ func TestAgentConnection_ExecuteConnectionCanceled(t *testing.T) {
h.cancel()
_, err := h.agent.Execute(context.Background(), domainHub.AgentRequest{Name: "test"})
assert.ErrorIs(t, err, ConnectionCloseErr)
assert.ErrorIs(t, err, ErrConnectionClose)
}
func TestAgentConnection_UnknownResponseID(t *testing.T) {