heesung-sn commented on code in PR #1210:
URL: https://github.com/apache/pulsar-client-go/pull/1210#discussion_r1618036642
##########
pulsar/internal/connection.go:
##########
@@ -928,6 +937,51 @@ func (c *connection) handleCloseProducer(closeProducer
*pb.CommandCloseProducer)
}
}
+func (c *connection) getMigratedBrokerServiceURL(commandTopicMigrated
*pb.CommandTopicMigrated) string {
+ if c.tlsOptions == nil {
+ if commandTopicMigrated.GetBrokerServiceUrl() != "" {
+ return commandTopicMigrated.GetBrokerServiceUrl()
+ }
+ } else if commandTopicMigrated.GetBrokerServiceUrlTls() != "" {
+ return commandTopicMigrated.GetBrokerServiceUrlTls()
+ }
+ return ""
+}
+
+func (c *connection) handleTopicMigrated(commandTopicMigrated
*pb.CommandTopicMigrated) {
+ resourceID := commandTopicMigrated.GetResourceId()
+ migratedBrokerServiceURL :=
c.getMigratedBrokerServiceURL(commandTopicMigrated)
+ if migratedBrokerServiceURL == "" {
+ c.log.Warnf("Failed to find the migrated broker url for
resource: %s, migratedBrokerUrl: %s, migratedBrokerUrlTls:%s",
+ resourceID,
+ commandTopicMigrated.GetBrokerServiceUrl(),
+ commandTopicMigrated.GetBrokerServiceUrlTls())
+ return
+ }
+ if commandTopicMigrated.ResourceType.Number() == 0 {
Review Comment:
updated.
##########
pulsar/internal/connection.go:
##########
@@ -928,6 +937,51 @@ func (c *connection) handleCloseProducer(closeProducer
*pb.CommandCloseProducer)
}
}
+func (c *connection) getMigratedBrokerServiceURL(commandTopicMigrated
*pb.CommandTopicMigrated) string {
+ if c.tlsOptions == nil {
+ if commandTopicMigrated.GetBrokerServiceUrl() != "" {
+ return commandTopicMigrated.GetBrokerServiceUrl()
+ }
+ } else if commandTopicMigrated.GetBrokerServiceUrlTls() != "" {
+ return commandTopicMigrated.GetBrokerServiceUrlTls()
+ }
+ return ""
+}
+
+func (c *connection) handleTopicMigrated(commandTopicMigrated
*pb.CommandTopicMigrated) {
+ resourceID := commandTopicMigrated.GetResourceId()
+ migratedBrokerServiceURL :=
c.getMigratedBrokerServiceURL(commandTopicMigrated)
+ if migratedBrokerServiceURL == "" {
+ c.log.Warnf("Failed to find the migrated broker url for
resource: %s, migratedBrokerUrl: %s, migratedBrokerUrlTls:%s",
+ resourceID,
+ commandTopicMigrated.GetBrokerServiceUrl(),
+ commandTopicMigrated.GetBrokerServiceUrlTls())
+ return
+ }
+ if commandTopicMigrated.ResourceType.Number() == 0 {
+ c.listenersLock.RLock()
+ producer, ok := c.listeners[resourceID]
+ c.listenersLock.RUnlock()
+ if ok {
+
producer.SetRedirectedClusterURI(migratedBrokerServiceURL)
+ c.log.Infof("producerID:{%d} migrated to
RedirectedClusterURI:{%s}",
+ resourceID, migratedBrokerServiceURL)
+ } else {
+ c.log.WithField("producerID", resourceID).Warn("Failed
to SetRedirectedClusterURI")
+ }
+ } else {
+ consumer, ok := c.consumerHandler(resourceID)
Review Comment:
Unfortunately, this may require some significant refactoring, as the
Listener is mainly for producer, as its interface shows.
```go
type ConnectionListener interface {
// ReceivedSendReceipt receive and process the return value of the send
command.
ReceivedSendReceipt(response *pb.CommandSendReceipt)
// ConnectionClosed close the TCP connection.
ConnectionClosed(closeProducer *pb.CommandCloseProducer)
// SetRedirectedClusterURI set the redirected cluster URI for lookups
SetRedirectedClusterURI(redirectedClusterURI string)
}
```
--
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]