labuladong commented on code in PR #848:
URL: https://github.com/apache/pulsar-client-go/pull/848#discussion_r991802251


##########
pulsar/consumer_regex.go:
##########
@@ -37,73 +35,36 @@ const (
 )
 
 type regexConsumer struct {
-       client *client
-       dlq    *dlqRouter
-       rlq    *retryRouter
-
-       options ConsumerOptions
-
-       messageCh chan ConsumerMessage
+       *multiTopicConsumer
 
        namespace string
        pattern   *regexp.Regexp
 
        consumersLock sync.Mutex
-       consumers     map[string]Consumer
        subscribeCh   chan []string
        unsubscribeCh chan []string
-
-       closeOnce sync.Once
-       closeCh   chan struct{}
-
-       ticker *time.Ticker
-
-       log log.Logger
-
-       consumerName string
+       ticker        *time.Ticker
 }
 
-func newRegexConsumer(c *client, opts ConsumerOptions, tn *internal.TopicName, 
pattern *regexp.Regexp,
-       msgCh chan ConsumerMessage, dlq *dlqRouter, rlq *retryRouter) 
(Consumer, error) {
+func newRegexConsumer(client *client, opts ConsumerOptions, tn 
*internal.TopicName, pattern *regexp.Regexp,
+       msgCh chan ConsumerMessage, dlq *dlqRouter, rlq *retryRouter) 
(*regexConsumer, error) {
+       topics, err := topics(client, tn.Namespace, pattern)
+       if err != nil {
+               return nil, err
+       }
+       mtc, err := newMultiTopicConsumer(client, opts, topics, msgCh, dlq, rlq)
+       if err != nil {
+               return nil, err

Review Comment:
   > Can we make this function as part of struct method?
   
   Hi @zzzming. In the original implementation, `topics` is a method of 
`regexConsumer` struct. In the new  implementation, we need to get the topics 
before initialize `regexConsumer`. But I think make this `topics` function as 
method of `client` struct will be better, I will work on this.



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

Reply via email to