Skip to content

Scala wrapper for kafka consumer and producer

License

Notifications You must be signed in to change notification settings

Z1kkurat/skafka

 
 

Repository files navigation

Skafka

Build Status Coverage Status Codacy Badge Version License: MIT

Scala wrapper for kafka-clients v2.7.1

Key features

  1. It provides null-less Scala apis for Producer & Consumer

  2. Makes it easy to use your effect monad with help of cats-effect

  3. Blocking calls are being executed on provided ExecutionContext.

  4. Simple case class based configuration

  5. Support of typesafe config

Producer usage example

val producer = Producer.of[IO](config, ecBlocking)
val metadata: IO[RecordMetadata] = producer.use { producer =>
  val record = ProducerRecord(topic = "topic", key = "key", value = "value") 
  producer.send(record).flatten 
}

Consumer usage example

val consumer = Consumer.of[IO, String, String](config, ecBlocking)
val records: IO[ConsumerRecords[String, String]] = consumer.use { consumer => 
  for {
    _       <- consumer.subscribe(Nel("topic"), None)
    records <- consumer.poll(100.millis)
  } yield records 
}

Setup

addSbtPlugin("com.evolution" % "sbt-artifactory-plugin" % "0.0.2")

libraryDependencies += "com.evolutiongaming" %% "skafka" % "11.5.0"

About

Scala wrapper for kafka consumer and producer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 100.0%