goncalo-rodrigues commented on code in PR #1141:
URL: https://github.com/apache/pulsar-client-go/pull/1141#discussion_r1417209866


##########
pulsar/consumer_regex.go:
##########
@@ -320,6 +319,25 @@ func (c *regexConsumer) closed() bool {
 }
 
 func (c *regexConsumer) monitor() {
+       defer close(c.subscribeCh)
+       defer close(c.unsubscribeCh)
+
+       go func() {
+               for topics := range c.subscribeCh {
+                       if len(topics) > 0 && !c.closed() {
+                               c.subscribe(topics, c.dlq, c.rlq)
+                       }
+               }
+       }()
+
+       go func() {
+               for topics := range c.unsubscribeCh {
+                       if len(topics) > 0 && !c.closed() {
+                               c.unsubscribe(topics)
+                       }
+               }
+       }()

Review Comment:
   That's a good point. I would go one step further and simplify this logic to 
not use channels but rather process subscriptions in the thread that processes 
the ticker. What do you think?
   
   Theres no point to the channels as there's a single producer and a single 
consumer. And this already runs in a separate goroutine specific to the auto 
discovery of topics. If in the future we have additional producers then 
channels can be reintroduced with any new requirements in mind.



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