-
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,13 @@ func (b *fetchRequestBlock) decode(pd packetDecoder) (err error) { | |
return nil | ||
} | ||
|
||
// FetchRequest (API key 1) will fetch Kafka messages. Version 3 introduced the MaxBytes field. See | ||
// https://issues.apache.org/jira/browse/KAFKA-2063 for a discussion of the issues leading up to that. The KIP is at | ||
// https://cwiki.apache.org/confluence/display/KAFKA/KIP-74%3A+Add+Fetch+Response+Size+Limit+in+Bytes | ||
type FetchRequest struct { | ||
MaxWaitTime int32 | ||
MinBytes int32 | ||
MaxBytes int32 | ||
Version int16 | ||
blocks map[string]map[int32]*fetchRequestBlock | ||
} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Old habits die hard; fixed in my latest commit. |
||
pe.putInt32(r.MaxBytes) | ||
} | ||
err = pe.putArrayLength(len(r.blocks)) | ||
if err != nil { | ||
return err | ||
|
@@ -67,6 +74,11 @@ func (r *FetchRequest) decode(pd packetDecoder, version int16) (err error) { | |
if r.MinBytes, err = pd.getInt32(); err != nil { | ||
return err | ||
} | ||
if r.Version == 3 { | ||
if r.MaxBytes, err = pd.getInt32(); err != nil { | ||
return err | ||
} | ||
} | ||
topicCount, err := pd.getArrayLength() | ||
if err != nil { | ||
return err | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.