-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Added support for FetchRequest protocol version 3. #905
Conversation
This commit will add the 'MaxBytes' field to FetchRequests when the Kafka version is 0.10.1 or better. On send, it will be set to MaxResponseSize. No tests, yet.
This commit adds support for version 3 of the FetchRequest API. The KIP can be found here: https://cwiki.apache.org/confluence/display/KAFKA/KIP-74%3A+Add+Fetch+Response+Size+Limit+in+Bytes the PR here: apache/kafka#1812 and the JIRA here: https://issues.apache.org/jira/browse/KAFKA-2063 Should document the fact that the per-partition limits take precedence (so the returned message may be larger than the requested limit).
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.
Thank you, this looks pretty good. Just have a few questions.
fetch_request.go
Outdated
@@ -32,6 +36,9 @@ func (r *FetchRequest) encode(pe packetEncoder) (err error) { | |||
pe.putInt32(-1) // replica ID is always -1 for clients | |||
pe.putInt32(r.MaxWaitTime) | |||
pe.putInt32(r.MinBytes) | |||
if 3 == r.Version { |
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.
r.Version == 3
is more consistent with the rest of the code, and with the check you added below
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.
Old habits die hard; fixed in my latest commit.
consumer.go
Outdated
@@ -726,6 +726,10 @@ func (bc *brokerConsumer) fetchNewMessages() (*FetchResponse, error) { | |||
if bc.consumer.conf.Version.IsAtLeast(V0_10_0_0) { | |||
request.Version = 2 | |||
} | |||
if bc.consumer.conf.Version.IsAtLeast(V0_10_1_0) { | |||
request.Version = 3 | |||
request.MaxBytes = MaxResponseSize - 47 // TODO(mherstin): WTF?! |
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.
I agree with the comment: where did the value of 47 come from?
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.
That's embarrassing-- this was removed in a subsequent commit which I forgot to push. Fixed.
Thanks! |
This commit will add the 'MaxBytes' field to FetchRequests when the Kafka version is
0.10.1 or better (i.e. it adds support for V3 of the FetchRequest API). On send, it will be set to MaxResponseSize.