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

Support for producing unkeyed messages #96

Closed
ranjanibrickx opened this issue Feb 28, 2019 · 4 comments
Closed

Support for producing unkeyed messages #96

ranjanibrickx opened this issue Feb 28, 2019 · 4 comments

Comments

@ranjanibrickx
Copy link

Hello,

First of all, thank you for the https://github.com/ovotech/fs2-kafka-client as well as https://github.com/ovotech/fs2-kafka libraries!

I was looking at switching to the latest kafka version, and was looking to move to this (fs2-kafka) library. One question I had was if there is any plan to support unkeyed records in this library?

@vlovgr
Copy link
Contributor

vlovgr commented Feb 28, 2019

Thanks for raising this issue @ranjanibrickx!

[...] any plan to support unkeyed records in this library?

What kind of support are you looking for? If all records are unkeyed, you can easily define the serializer and deserializer as follows, and use them as the keySerializer and keyDeserializer when creating ProducerSettings and ConsumerSettings, respectively. Simply provide the unit value () as key when serializing records. (We could add these to the library as Serializer.unit and Deserializer.unit.)

Serializer.const[Unit](null)
Deserializer.const[Unit](())

If you have a mix of unkeyed and keyed records, and want the keys when available, we could add a Deserializer#option function which gives you None for unkeyed records, so you could do something like Deserializer[String].option.

@vlovgr
Copy link
Contributor

vlovgr commented Feb 28, 2019

@ranjanibrickx I've opened #97 to include the mentioned additions, and some more. The pull request contains further explanations. Is there any anything else you're missing?

@ranjanibrickx
Copy link
Author

Thanks a lot for the quick and helpful response! For the moment, we have all messages on a topic as unkeyed records, so what you proposed as the first option works perfectly -- I had missed that when I was exploring yesterday! But thank you for creating the PR to introduce the support for a mix of unkeyed and keyed messages too!

@vlovgr vlovgr closed this as completed in #97 Mar 1, 2019
@vlovgr
Copy link
Contributor

vlovgr commented Mar 1, 2019

@ranjanibrickx The changes in #97 are included in the 0.19.4 release.

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

No branches or pull requests

2 participants