
com.avsystem.commons.kafka.VersionedSerializer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons-kafka_2.12 Show documentation
Show all versions of commons-kafka_2.12 Show documentation
AVSystem commons library for Scala
The newest version!
package com.avsystem.commons
package kafka
import java.io.ByteArrayOutputStream
import com.avsystem.commons.serialization.GenCodec
class VersionedSerializer[T](version: Byte)(implicit codec: GenCodec[T]) extends AbstractSerializer[T] {
private val serde = new CodecSerde(codec)
override def serialize(topic: String, data: T): Array[Byte] = {
val output = new ByteArrayOutputStream()
output.write(version)
serde.serialize(output, data)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy