WIP: [Issue 218] Add Seek functions to Reader - #222
Conversation
|
|
Move this change to 0.2.0 |
| 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 | ||
| } |
There was a problem hiding this 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 #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.
| assert.Equal(t, 10, i) | ||
| } | ||
|
|
||
| func TestReaderSeek(t *testing.T) { |
There was a problem hiding this comment.
There can be an added test case which does a Seek on a custom MessageID refer to #305
Signed-off-by: xiaolong.ran <rxl@apache.org> ### Motivation Follow #222 and add the seek logic for reader ### Modifications - Add `seek by msgID` interface - Add `seek by time` interface - Add test case ### Verifying this change - [x] Make sure that the change passes the CI checks.
Fixes #218
WIP due to
TestReaderSeekhanging when executingreader.Next()afterreader.Seek()- not sure why this happens and how to continue here, any help or hint is welcome.Motivation
Seek()was missing inReaderinterface but is available in the C++ client lib.Modifications
ConsumerdoesVerifying this change
This change added tests and can be verified as follows:
TestReaderSeek*Does this pull request potentially affect one of the following parts:
Documentation