shohi commented on a change in pull request #360:
URL: https://github.com/apache/pulsar-client-go/pull/360#discussion_r476247043
##########
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:
my bad, the handling logic is correct :-)
What i mean is to wrap the test logic, like following
```go
func (p *partitionProducer) shouldRetry() bool {
maxReconnects := p.opts.MaxReconnectToBroker
switch {
case maxReconnects < 0:
return true
case maxReconnects == 0:
return false
default:
p.reconnectAttempts++
if p.reconnectAttempts > maxReconnects {
return false
}
return true
}
}
func (p *partitionProducer) reconnectToBroker() {
for p.shouldRetry() {
// retry logic
}
}
```
----------------------------------------------------------------
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]