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

Change to improve working with unkeyed records #97

Merged
merged 4 commits into from
Mar 1, 2019
Merged

Conversation

vlovgr
Copy link
Contributor

@vlovgr vlovgr commented Feb 28, 2019

This pull request aims to make it easier to work with unkeyed records.

If all records are unkeyed, simply use Unit serializers and deserializers. These are available implicitly as Serializer.unit and Deserializer.unit, so you can use ProducerSettings[Unit, V] and ConsumerSettings[Unit, V].

If some records are keyed and some are not, use Serializer#option and Deserializer#option, also available implicitly via Serializer.option and Deserializer.option. These serializers representNone as null in serialized form. Similarly, you can use these via ProducerSettings[Option[K], V] and ConsumerSettings[Option[K], V].

For more complex types and cases, there is Serializer.asNull[A] and Serializer.empty[A] which serializes arbitrary values of a given type as null or the empty Array[Byte], respectively.

For parity, similar additions have been made to HeaderSerializer and HeaderDeserializer.

Detailed changes:

  • Add Deserializer#option, and Deserializer.option and unit.
  • Add HeaderDeserializer#option and HeaderDeserializer.option and unit.
  • Add Serializer#option, and Serializer.option, asNull, empty and unit.
  • Add HeaderSerializer#option, and Serializer.option, asNull, empty and unit.

Fixes #96.

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #97 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #97      +/-   ##
=========================================
+ Coverage   98.87%   98.9%   +0.02%     
=========================================
  Files          38      38              
  Lines         978    1004      +26     
  Branches       51      62      +11     
=========================================
+ Hits          967     993      +26     
  Misses         11      11
Impacted Files Coverage Δ
src/main/scala/fs2/kafka/Serializer.scala 100% <100%> (ø) ⬆️
src/main/scala/fs2/kafka/HeaderDeserializer.scala 100% <100%> (ø) ⬆️
src/main/scala/fs2/kafka/Deserializer.scala 100% <100%> (ø) ⬆️
src/main/scala/fs2/kafka/HeaderSerializer.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ffdb23c...a8ecc4d. Read the comment docs.

@vlovgr vlovgr merged commit 0c64228 into master Mar 1, 2019
@vlovgr vlovgr deleted the unkeyed-records branch March 1, 2019 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant