This is an automated email from the ASF dual-hosted git repository.

hgruszecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new 185215fbe fix(go): fix tcp client connect method (#2860)
185215fbe is described below

commit 185215fbe84b252e9adff61a4f235aec2a236a36
Author: Chengxi Luo <[email protected]>
AuthorDate: Thu Mar 5 04:50:21 2026 -0500

    fix(go): fix tcp client connect method (#2860)
---
 foreign/go/client/tcp/tcp_core.go | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/foreign/go/client/tcp/tcp_core.go 
b/foreign/go/client/tcp/tcp_core.go
index 0d6073164..c5a74b772 100644
--- a/foreign/go/client/tcp/tcp_core.go
+++ b/foreign/go/client/tcp/tcp_core.go
@@ -327,21 +327,18 @@ func (c *IggyTcpClient) connect() error {
                        time.Sleep(remaining)
                }
        }
-
+       attempts := uint(1)
+       interval := time.Duration(0)
+       if c.config.reconnection.enabled {
+               attempts = uint(c.config.reconnection.maxRetries)
+               interval = c.config.reconnection.interval
+       }
        // TODO handle tls logic
        var conn net.Conn
        if err := retry.Do(
                func() error {
                        connection, err := net.Dial("tcp", 
c.currentServerAddress)
                        if err != nil {
-                               if !c.config.reconnection.enabled {
-                                       return 
retry.Unrecoverable(ierror.ErrCannotEstablishConnection)
-                               }
-
-                               c.mtx.Lock()
-                               c.state = iggcon.StateDisconnected
-                               c.mtx.Unlock()
-                               // TODO publish event disconnected
                                return ierror.ErrCannotEstablishConnection
                        }
 
@@ -372,9 +369,13 @@ func (c *IggyTcpClient) connect() error {
                        conn = tlsConn
                        return nil
                },
-               retry.Attempts(uint(c.config.reconnection.maxRetries)),
-               retry.Delay(c.config.reconnection.interval),
+               retry.Attempts(attempts),
+               retry.Delay(interval),
        ); err != nil {
+               c.mtx.Lock()
+               c.state = iggcon.StateDisconnected
+               c.mtx.Unlock()
+               // TODO publish event disconnected
                return err
        }
 

Reply via email to