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

Invalid documentation for NewHashPartitioner #717

Closed
AlekSi opened this issue Aug 3, 2016 · 1 comment
Closed

Invalid documentation for NewHashPartitioner #717

AlekSi opened this issue Aug 3, 2016 · 1 comment

Comments

@AlekSi
Copy link

AlekSi commented Aug 3, 2016

Sarama Version: v1.10

https://godoc.org/gopkg.in/Shopify/sarama.v1#NewHashPartitioner says:

If the message's key is nil, or fails to encode, then a random partition is chosen.

But code actually returns -1 in case of encoding error, which results in ErrInvalidPartition.

@eapache
Copy link
Contributor

eapache commented Aug 9, 2016

It actually returns -1 and the encoding error, so the producer should just pass along the encoding error rather than trying to treat the -1 as a partition (https://github.com/Shopify/sarama/blob/9bb4a68d57ff6f623363aa172f0a8297aa289ba7/async_producer.go#L346-L349). The behaviour makes sense as-is, I will fix the documentation.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants