-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Offset enhancement for consumer #162
Conversation
Overall: I like the proposal. I think it's a really great way to handle offset management. There was some great commentary on absolute offsets a while back in another issue, and I'm not sure that there is any kind of sensible meaning in seeking to an absolute offset in a multipartition consumer. Absolute seeks really only make sense when consuming from a single partition. |
Also, the Travis CI build is failing. I think it might be because the Travis build still uses Kafka 0.8.0. Did the tests work for you locally? |
Mark, thanks for the nice review. I will revise the code. |
I think a practical solution would be to raise ValueError if len(partitions) > 1. There was talk of breaking seek() up. The previous discussion was here: #146 |
FWIW, if you end up having test code that relies on Kafka 0.8.1, I have a branch that allows you to test against it (PR #158). |
Yes, I have tested it with Kafka 0.8.1 and we are using it. Thanks for the reference about the branch for test. |
#Zero = 0 # start from 0, may not be available due | ||
# to ttl | ||
|
||
Previous = -1 # position stores in zookeeper last time |
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.
Style: Recommend that you refactor all constants be in capitals with underscores, e.g. PREVIOUS
See PEP 8
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.
Fixed. Thanks @girlprogrammer
@wizzat Could you tell me how to use your Kafka 0.8.1 branch? |
Sure, So I'd make a branch (of your branch) and merge the 0.8.1 branch in. Then run ./build_integration.sh and:
Optionally you can pass in the |
I think something like this is important to merge, but I have a few thoughts on implementation: (1) I dont like passing in a single absolute offset to a consumer that is currently topic-focused. That isn't going to make sense for multi-partition topics. is this PR still active? it looks like there have been a lot of changes to the master branch that would need to be merged in. if not active, it probably makes sense to create a separate PR |
I believe this is addressed in 0.9.4 / #296 with SimpleConsumer.reset_partition_offset |
Too many MRs to review... so little time.
Too many MRs to review... so little time.
Offset enhancement for consumer. User can pass offset as a parameter to consumer, with the following values:
Previous (-1): position stores in zookeeper last time;
CurrentBeginning (-2): current beginning offset (may not be 0 due to TTL);
PreviousOrCurrentBeginning (-3): Get previous offset firstly, if not available, use current beginning;
Latest (-4): Start from latest, like tail;
Any other value >= 0: actual offset, raise exception if the offset is invalid.
Yongkun Wang and KiranRaj Mariyappa