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

Proposal: Implement message keys as bytes instead of strings #81

Closed
burdiyan opened this issue Jan 31, 2018 · 2 comments
Closed

Proposal: Implement message keys as bytes instead of strings #81

burdiyan opened this issue Jan 31, 2018 · 2 comments

Comments

@burdiyan
Copy link
Contributor

This is rather a proposal for future versions, as it will be a breaking change.

The thing is that, message keys in Kafka are bytes, so can be not only simple strings, but also complex structures encoded as bytes.

For example we use Debezium (http://debezium.io) for doing Change Data Capture from MySQL databases, and Debezium uses table's primary key as message key for Kafka. It is commonly encoded with Avro as a struct like {"id": 1}.

Right now in order to deal with this, we need to pass goka.UpdateCallback everywhere, that would convert key string back to []byte, deserialize it to struct and then store only the int value converted to string as a table's key.

Using []byte for keys would just be more clear semantically for many Kafka users, since that is how Kafka works internally.

@frairon
Copy link
Contributor

frairon commented Feb 7, 2018

Initially we implemented storing keys as bytes as well, but it turned out that we never had any use case for bytes and tried to avoid the continuous casting of strings for convenience.

I could imagine implementing a key conversion based on codecs. That way each topic could have individual ways of storing and accessing their keys. All functions would then be be passed just an interface{} like with the values.
But as you said, it's a breaking change (or add many similar-looking functions to the interface), and probably not too urgent at the moment.

Many thanks for giving that hint anyways!

@burdiyan
Copy link
Contributor Author

burdiyan commented Feb 7, 2018

I actually ended up using strings all the time (it turnes out there is a way to configure Kafka Connect inputs to extract the field from the key structure). Basically I also think it's rare to use complex structures for message keys. So I'd rather close this issue.

@burdiyan burdiyan closed this as completed Feb 7, 2018
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