cckellogg commented on a change in pull request #109: Fix subscriber bug and
use Consumer interface for multi topic consumer.
URL: https://github.com/apache/pulsar-client-go/pull/109#discussion_r352298820
##########
File path: pulsar/consumer_multitopic.go
##########
@@ -45,54 +45,32 @@ func newMultiTopicConsumer(client *client, options
ConsumerOptions, topics []str
mtc := &multiTopicConsumer{
options: options,
messageCh: messageCh,
- consumers: make(map[string]*consumer, len(topics)),
+ consumers: make(map[string]Consumer, len(topics)),
closeCh: make(chan struct{}),
log: &log.Entry{},
}
- type ConsumerError struct {
- err error
- topic string
- consumer *consumer
- }
-
- var wg sync.WaitGroup
- wg.Add(len(topics))
- ch := make(chan ConsumerError, len(topics))
- for i := range topics {
- go func(t string) {
- defer wg.Done()
- c, err := internalTopicSubscribe(client, options, t,
messageCh)
- ch <- ConsumerError{
- err: err,
- topic: t,
- consumer: c,
- }
- }(topics[i])
- }
-
- go func() {
- wg.Wait()
- close(ch)
- }()
-
var errs error
- for ce := range ch {
+ consumers := make(map[string]Consumer, len(topics))
Review comment:
That's a good question. The idea was to only set the consumers when
everything succeeded but I don't think it matters since we return nil on
failure. I'll remove it.
----------------------------------------------------------------
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