kafka-serde-scala provides implicit conversions from different type class Encoder/Decoder to kafka Serializer, Deserializer, Serde.
Following target libraries are supported:
Inspired by https://github.com/hseeberger/akka-http-json.
Add dependencies for the selected integration:
for avro4s:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-avro4s" % version
)
for circe:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-circe" % version
)
for jackson:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-jackson" % version
)
for json4s:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-json4s" % version
)
for jsoniter-scala:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-jsoniter-scala" % version,
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % jsoniter_scala_version % Provided // required only in compile-time
)
for play-json:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-play-json" % version
)
for upickle:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-upickle" % version
)
for scalapb:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-scalapb" % version
)
for zio-json:
libraryDependencies ++= List(
"io.github.azhur" %% "kafka-serde-zio-json" % version
)
Mix xxxSupport
into your code which requires implicit Kafka
Serde
, Serializer
or Deserializer
, where xxx
is the target library used for serialization, i.e: CirceSupport.
Provide your implicit type class instances and the magic will convert them to Kafka serializers:
com.sksamuel.avro4s.SchemaFor[T]
, com.sksamuel.avro4s.ToRecord[T]
, com.sksamuel.avro4s.FromRecord[T]
io.circe.Encoder[T]
, io.circe.Decoder[T]
com.fasterxml.jackson.databind.ObjectMapper
com.fasterxml.jackson.databind.ObjectMapper
, org.codehaus.jackson.FormatSchema
org.json4s.DefaultFormats
, org.json4s.Serialization
com.github.plokhotnyuk.jsoniter_scala.core.JsonValueCodec[T]
, (and optionally
com.github.plokhotnyuk.jsoniter_scala.core.WriterConfig
or/and com.github.plokhotnyuk.jsoniter_scala.core.ReaderConfig
)play.api.libs.json.Reads
, play.api.libs.json.Writes
upickle.default.Reader
, upickle.default.Writer
scalapb.GeneratedMessageCompanion
zio.json.JsonEncoder
, zio.json.JsonDecoder
For more info, please, take a look at unit tests and at kafka-serde-scala-example
which is a kafka-streams (2.x) application with kafka-serde-scala usage.
Feel free to contribute with creating PR or opening issues.
This code is open source software licensed under the Apache 2.0 License.