Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joan38/kafka-streams-circe
Generic Serdes with Circe for Kafka Streams
https://github.com/joan38/kafka-streams-circe
Last synced: about 2 months ago
JSON representation
Generic Serdes with Circe for Kafka Streams
- Host: GitHub
- URL: https://github.com/joan38/kafka-streams-circe
- Owner: joan38
- License: apache-2.0
- Created: 2018-04-30T12:14:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-06T17:20:00.000Z (over 2 years ago)
- Last Synced: 2024-10-22T04:50:19.990Z (2 months ago)
- Language: Scala
- Homepage:
- Size: 31.3 KB
- Stars: 28
- Watchers: 4
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kafka Streams Circe
[![Latest version](https://index.scala-lang.org/joan38/kafka-streams-circe/kafka-streams-circe/latest.svg)](https://index.scala-lang.org/joan38/kafka-streams-circe/kafka-streams-circe)
Generic Serdes with [Circe](https://github.com/circe/circe) for [Kafka Streams](https://github.com/apache/kafka)
## Installation
[Mill](https://www.lihaoyi.com/mill):
```scala
ivy"com.goyeau::kafka-streams-circe:"
```
or[SBT](https://www.scala-sbt.org):
```scala
"com.goyeau" %% "kafka-streams-circe" % ""
```## Example
```scala
import org.apache.kafka.streams.scala.StreamsBuilder
import org.apache.kafka.streams.scala.ImplicitConversions._
import org.apache.kafka.streams.scala.Serdes._
import com.goyeau.kafka.streams.circe.CirceSerdes._
import io.circe.generic.auto._case class Person(firstname: String, lastname: String, age: Int)
object Streams extends App {
println("Starting streams")val streamsBuilder = new StreamsBuilder
val testStream = streamsBuilder.stream[String, Person]("some-topic")
}
```If you need to customize the json serialization, a custom implicit instance of `Printer` can be provided in scope.
For example, in the code below a custom printer is used to omit null values:
```scala
import org.apache.kafka.streams.scala.StreamsBuilder
import org.apache.kafka.streams.scala.ImplicitConversions._
import org.apache.kafka.streams.scala.Serdes._
import com.goyeau.kafka.streams.circe.CirceSerdes._
import io.circe.generic.auto._case class Person(firstname: String, lastname: String, age: Int)
object Streams extends App {
implicit val printer = Printer.noSpaces.copy(dropNullValues = true)val streamsBuilder = new StreamsBuilder
val testStream = streamsBuilder.stream[String, Person]("some-topic")
}
```