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
Serde followups #44
Serde followups #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
def deserializeWith[R, K1, V1]( | ||
keyDeserializer: Deserializer[R, K1], | ||
valueDeserializer: Deserializer[R, V1] | ||
)(implicit ev1: K <:< Array[Byte], ev2: V <:< Array[Byte]): RIO[R, CommittableRecord[K1, V1]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting trick this subtype evidence, never used it before.
@@ -93,8 +93,8 @@ object Producer { | |||
r: ProducerRecord[K, V] | |||
): RIO[R, ByteArrayProducerRecord] = | |||
for { | |||
key <- keySerializer.serialize(r.key()) | |||
value <- valueSerializer.serialize(r.value()) | |||
key <- keySerializer.serialize(r.topic, r.headers, r.key()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I never saw the need for the serializer to know the topic and headers, but I like the idea of not imposing that.
/** | ||
* Obtain an instance of a Serializer of some type from the implicit scope | ||
*/ | ||
def of[T](implicit ser: Serializer[Any, T]): Serializer[Any, T] = ser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for removing the of
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to move away from encouraging users to use implicit scope for the serializer/deserializer instances.
In other words - not treat them like typeclasses at all, but rather as simple functions.
@@ -48,7 +48,7 @@ class ConsumerTest extends WordSpecLike with Matchers with LazyLogging with Defa | |||
_ <- consumer.subscribe(Subscription.Topics(Set("topic150"))) | |||
kvs <- ZIO((1 to 5).toList.map(i => (s"key$i", s"msg$i"))) | |||
_ <- produceMany("topic150", kvs) | |||
records <- consumer.plainStream(Serde.of[String], Serde.of[String]).flattenChunks.take(5).runCollect | |||
records <- consumer.plainStream(Serde.string, Serde.string).flattenChunks.take(5).runCollect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that for the primitive serdes there's no advantage of Serde.of[String]
over Serde.string
.
@svroonland - could you have a look?