jonyhy96 commented on a change in pull request #360:
URL: https://github.com/apache/pulsar-client-go/pull/360#discussion_r476255226



##########
File path: pulsar/producer_partition.go
##########
@@ -236,8 +236,18 @@ func (p *partitionProducer) ConnectionClosed() {
 }
 
 func (p *partitionProducer) reconnectToBroker() {
-       backoff := internal.Backoff{}
-       for {
+       var (
+               maxRetry int
+               backoff  = internal.Backoff{}
+       )
+
+       if p.options.MaxReconnectToBroker == nil {
+               maxRetry = -1
+       } else {
+               maxRetry = int(*p.options.MaxReconnectToBroker)
+       }

Review comment:
       Great, This looks more clear. 
   I think it would be better if we decide the type of 
p.opts.MaxReconnectToBroker first.
   Besides, i think `shouldRetry()` logic maybe a little bit slower than the 
origin one, we can reduce the `shouldRetry()` call times by move some common 
logic outside of the for loop. 




----------------------------------------------------------------
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.

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


Reply via email to