[client] Fix error handling in Receive to properly re-establish stream and improve reconnection messaging

This commit is contained in:
Zoltán Papp
2026-03-31 15:50:03 +02:00
parent a178ec785d
commit 8ba4183acd

View File

@@ -108,7 +108,7 @@ func (c *GRPCClient) Send(event *proto.FlowEvent) error {
func (c *GRPCClient) Receive(ctx context.Context, interval time.Duration, msgHandler func(msg *proto.FlowEventAck) error) error {
backOff := defaultBackoff(ctx, interval)
operation := func() error {
if err := c.establishStreamAndReceive(ctx, msgHandler); err != nil {
if err := c.establishStreamAndReceive(ctx, msgHandler); err == nil {
if errors.Is(err, context.Canceled) {
return backoff.Permanent(err)
}
@@ -124,7 +124,7 @@ func (c *GRPCClient) Receive(ctx context.Context, interval time.Duration, msgHan
return err
}
log.Infof("connection recreated successfully")
return nil
return fmt.Errorf("connection recreated, re-establishing stream")
}
}