nitishv commented on a change in pull request #222:
URL: https://github.com/apache/pulsar-client-go/pull/222#discussion_r449955128
##########
File path: pulsar/reader_impl.go
##########
@@ -150,3 +151,33 @@ func (r *reader) hasMoreMessages() bool {
func (r *reader) Close() {
r.pc.Close()
}
+
+func (r *reader) messageID(msgID MessageID) (*messageID, bool) {
+ mid, ok := msgID.(*messageID)
+ if !ok {
+ r.log.Warnf("invalid message id type")
+ return nil, false
+ }
+
+ partition := mid.partitionIdx
+ // did we receive a valid partition index?
+ if partition != 0 {
+ r.log.Warnf("invalid partition index %d expected 0", partition)
+ return nil, false
+ }
+
+ return mid, true
+}
Review comment:
Given the method signature, the purpose of this method is to convert
MessageID to get *messageID
In doing so, a failure in type assertion is not really a failure. The given
msgID can still be converted. Refer to a this fix I just made
https://github.com/apache/pulsar-client-go/pull/305
I think that the mentioned PR change can be re-factored into this unexported
method for reader, as it being used in couple of places now with this feature.
Also checking for non-zero partition index does not seem to be the purpose
of this method, and should not be included here. That check is only relevant to
Seek APIs, and should be moved there.
----------------------------------------------------------------
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]