gunli commented on code in PR #1333:
URL: https://github.com/apache/pulsar-client-go/pull/1333#discussion_r1961668025
##########
pulsar/producer_partition.go:
##########
@@ -581,7 +581,8 @@ func (p *partitionProducer) runEventsLoop() {
}
case connectionClosed := <-p.connectClosedCh:
p.log.Info("runEventsLoop will reconnect in producer")
- p.reconnectToBroker(connectionClosed)
+ // reconnect to broker in a new goroutine so that it
won't block the event loop, see issue #1332
+ go p.reconnectToBroker(connectionClosed)
Review Comment:
> I hope we can use a single goroutinue to handle the reconnect, so like:
#691, and then add a variable to record the reconnection state.
>
> If this state is reconnecting, we don't send the request.
I think the `connection.State` is sufficient and timely enough to control
this, because the reconnection state of a producer relies on `connection.State`
and the notification from a `connection`. If the connection is closed, we
should stop sending. The problem is that the connection's implementation still
needs to be refactored, as I mentioned above: make the sending logic
synchronous and close the connection when receiving
`BaseCommand_CLOSE_PRODUCER` or `BaseCommand_CLOSE_CONSUMER`.
--
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]