You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by rx...@apache.org on 2020/03/16 11:41:01 UTC

[pulsar-client-go] branch master updated: [Issue 190] RequestTimeout bound client connection backoff (#191)

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

rxl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new 4dc7855  [Issue 190] RequestTimeout bound client connection backoff (#191)
4dc7855 is described below

commit 4dc7855f99dc0d14a4174e71792143fa47c6102f
Author: Ming <it...@gmail.com>
AuthorDate: Mon Mar 16 07:40:55 2020 -0400

    [Issue 190] RequestTimeout bound client connection backoff (#191)
    
    * RequestTimeout bound client connection backoff
    
    * fix lint error
---
 pulsar/internal/rpc_client.go | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pulsar/internal/rpc_client.go b/pulsar/internal/rpc_client.go
index a0c4fad..6613805 100644
--- a/pulsar/internal/rpc_client.go
+++ b/pulsar/internal/rpc_client.go
@@ -111,12 +111,13 @@ func (c *rpcClient) Request(logicalAddr *url.URL, physicalAddr *url.URL, request
 
 func (c *rpcClient) getConn(logicalAddr *url.URL, physicalAddr *url.URL) (Connection, error) {
 	cnx, err := c.pool.GetConnection(logicalAddr, physicalAddr)
-	backoff := new(Backoff)
+	backoff := Backoff{1 * time.Second}
+	startTime := time.Now()
 	var retryTime time.Duration
 	if err != nil {
-		for retryTime < c.requestTimeout {
+		for time.Since(startTime) < c.requestTimeout {
 			retryTime = backoff.Next()
-			c.log.Debugf("Reconnecting to broker in {%v}", retryTime)
+			c.log.Debugf("Reconnecting to broker in {%v} with timeout in {%v}", retryTime, c.requestTimeout)
 			time.Sleep(retryTime)
 			cnx, err = c.pool.GetConnection(logicalAddr, physicalAddr)
 			if err == nil {