Skip to content
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

Increase topic partition count API #533

Merged
merged 13 commits into from
Jan 24, 2018
Merged

Conversation

0x2c7
Copy link
Contributor

@0x2c7 0x2c7 commented Jan 23, 2018

Proposed usage

client.create_partitions_for("topic", num_partitions: 10)

This API is available after Kafka 1.0.0. The API is implemented based on official documentation. Currently, the interface doesn't support custom partition assignments because I don't think it aligns with the goal of the gem.

@0x2c7 0x2c7 mentioned this pull request Jan 23, 2018
# the topic
# @param timeout [Integer] a duration of time to wait for the new
# @param validate_only [Boolean] whether this request is to validate only
# without actually execute it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any use cases for validate_only in ruby-kafka – do you have any? Otherwise I think it's better to leave it out (and just pass false).

# @param version [Integer] API version.
# @return [Boolean]
def support_api?(api_key, version = nil)
@cluster.support_api?(api_key, version)
Copy link
Contributor

@dasch dasch Jan 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you rename support_api? to supports_api??

Actually, I'm not sure this method should be exposed at all. I don't think the client should deal with this – a method should simply raise an exception if the Kafka version doesn't support the APIs it needs.

Back to the original: can you rename support_api? to supports_api??

@@ -30,7 +30,8 @@ def write(bytes)
# @param boolean [Boolean]
# @return [nil]
def write_boolean(boolean)
write(boolean ? 0x1 : 0x0)
# Note: 0x1 is represented by 1 byte when being written into the socket
write(boolean ? write_int8(1) : write_int8(0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong – you're writing the result of write_int8.


example "create partitions" do
unless kafka.support_api?(Kafka::Protocol::CREATE_PARTITIONS_API)
skip("This Kafka version not support ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now I see why it might be handy to include support_api?.

Copy link
Contributor

@dasch dasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of comments!

@0x2c7
Copy link
Contributor Author

0x2c7 commented Jan 24, 2018

@dasch Updated as your comment. About the encoder#write_boolean, the comment is wrong. However, we still need to pack the boolean because 1 (Fixnum) will be converted to a String before being written down to the socket. So, the @io.write(0x1) actually writes string "1", not 8-bit boolean as we want.

@dasch
Copy link
Contributor

dasch commented Jan 24, 2018

@nguyenquangminh0711 in that case, shouldn't we just do boolean ? write_int8(1) : write_int8(0) and not the outer write?

@0x2c7
Copy link
Contributor Author

0x2c7 commented Jan 24, 2018

@dasch Oh you are right. The outer write is redundant. I updated it 👍

@dasch
Copy link
Contributor

dasch commented Jan 24, 2018

Thanks!

@dasch dasch merged commit 8e5c182 into zendesk:master Jan 24, 2018
@0x2c7 0x2c7 deleted the create-partitions-api branch January 24, 2018 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants