BewareMyPower commented on code in PR #1310:
URL: https://github.com/apache/pulsar-client-go/pull/1310#discussion_r1855713583


##########
pulsar/consumer_partition.go:
##########
@@ -1564,7 +1578,7 @@ func (pc *partitionConsumer) dispatcher() {
                                pc.log.Debug("skip dispatching messages when 
seeking")
                        }
                } else {
-                       queueCh = pc.queueCh
+                       queueCh = pc.queueCh.outCh

Review Comment:
   > I wanted to comment also that perhaps using two channels queueInCh and 
queueOutCh might help make the code more understandable and easier to maintain.
   
   I agree.
   
   > When is the variable needed and when is not is not very clear.
   
   It's only used here (in the `dispatcher()` method):
   
   ```go
                case msg, ok := <-queueCh:
                        if !ok {
                                return
                        }
   
                        queueMsg = msg
   ```
   
   It polls a message from `queueCh`. If the case is hit, then in the next 
loop, `queueCh` will be nil and it won't try to poll a message from `queueCh`. 
Instead, `nextMessage` will be the wrapped message so that it will reach here:
   
   ```go
                case messageCh <- nextMessage:
                        queueMsg = nil
   ```
   
   I admit it's a bit complicated. The current design comes from 
https://github.com/apache/pulsar-client-go/pull/86. I'd like not to do some 
refactoring in this PR so I just changed the actual message channel from 
`queueCh` to `queueCh.outCh`.
   
   And just as you mentioned, I agree that using two channels will be more 
clear so I will make some changes.



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