geniusjoe commented on code in PR #1457:
URL: https://github.com/apache/pulsar-client-go/pull/1457#discussion_r2746042373


##########
pulsar/producer_test.go:
##########
@@ -2952,3 +2953,135 @@ func TestPartitionUpdateFailed(t *testing.T) {
                time.Sleep(time.Second * 1)
        }
 }
+
+type testReconnectBackoffPolicy struct {
+       curBackoff, minBackoff, maxBackoff time.Duration
+       retryTime                          int
+       lock                               sync.Mutex
+}
+
+func newTestReconnectBackoffPolicy(minBackoff, maxBackoff time.Duration) 
*testReconnectBackoffPolicy {
+       return &testReconnectBackoffPolicy{
+               curBackoff: 0,
+               minBackoff: minBackoff,
+               maxBackoff: maxBackoff,
+       }
+}
+
+func (b *testReconnectBackoffPolicy) Next() time.Duration {
+       b.lock.Lock()
+       defer b.lock.Unlock()
+
+       // Double the delay each time
+       b.curBackoff += b.curBackoff

Review Comment:
   ```
        b.curBackoff += b.curBackoff
        if b.curBackoff.Nanoseconds() < b.minBackoff.Nanoseconds() {
                b.curBackoff = b.minBackoff
        } else if b.curBackoff.Nanoseconds() > b.maxBackoff.Nanoseconds() {
                b.curBackoff = b.maxBackoff
        }
        b.retryTime++
   ```
   There is no issue with the code here. When retrying for the first time, 
`b.curBackoff` is assigned the value of `b.minBackoff`. And `b.minBackoff` 
should never be 0.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to