jpzk / skafka

Scala wrapper for kafka consumer and producer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Skafka

Build Status Coverage Status Codacy Badge version License: MIT

Scala wrapper for kafka-clients v2.2.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

resolvers += Resolver.bintrayRepo("evolutiongaming", "maven")

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

About

Scala wrapper for kafka consumer and producer

License:MIT License


Languages

Language:Scala 100.0%