merlimat commented on a change in pull request #221: Auto update the client to 
handle changes in number of partitions
URL: https://github.com/apache/pulsar-client-go/pull/221#discussion_r408291331
 
 

 ##########
 File path: pulsar/consumer_impl.go
 ##########
 @@ -130,56 +135,106 @@ func internalTopicSubscribe(client *client, options 
ConsumerOptions, topic strin
                log:       log.WithField("topic", topic),
        }
 
-       partitions, err := client.TopicPartitions(topic)
+       if options.Name != "" {
+               consumer.consumerName = options.Name
+       } else {
+               consumer.consumerName = generateRandomName()
+       }
+
+       err := consumer.internalTopicSubscribeToPartitions()
        if err != nil {
                return nil, err
        }
 
-       numPartitions := len(partitions)
-       consumer.consumers = make([]*partitionConsumer, numPartitions)
+       // set up timer to monitor for new partitions being added
+       duration := options.AutoDiscoveryPeriod
+       if duration <= 0 {
+               duration = defaultAutoDiscoveryDuration
+       }
+       consumer.ticker = time.NewTicker(duration)
+
+       go func() {
 
 Review comment:
   Problem is that the `TopicPartitions()` will just return a list, so we don't 
necessarely know if it's 1 partition or no partitions. In any case, if the 
topic is not partitioned, it would not be possible to create a partitioned 
topic with same name. 

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


With regards,
Apache Git Services

Reply via email to