-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: [Issue 218] Add Seek functions to Reader #222
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -362,3 +365,108 @@ func TestReaderHasNext(t *testing.T) { | |||
|
|||
assert.Equal(t, 10, i) | |||
} | |||
|
|||
func TestReaderSeek(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be an added test case which does a Seek on a custom MessageID refer to #305
Signed-off-by: xiaolong.ran <[email protected]> ### 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
TestReaderSeek
hanging 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 inReader
interface but is available in the C++ client lib.Modifications
Consumer
doesVerifying 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