harness.kafka.ConsumerConfig.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of harness-kafka_3 Show documentation
Show all versions of harness-kafka_3 Show documentation
Miscellaneous libraries/utilities for Scala.
The newest version!
package harness.kafka
import zio.json.*
import zio.kafka.consumer.Consumer
final case class ConsumerConfig(
groupId: String,
topicName: String,
offsetStrategy: Consumer.AutoOffsetStrategy,
)
object ConsumerConfig {
private val offsetStrategyLowerMap: Map[String, Consumer.AutoOffsetStrategy] =
List(Consumer.AutoOffsetStrategy.Earliest, Consumer.AutoOffsetStrategy.Latest, Consumer.AutoOffsetStrategy.None).map(s => s.toString.toLowerCase -> s).toMap
private implicit val offsetStrategyJsonCodec: JsonCodec[Consumer.AutoOffsetStrategy] =
JsonCodec.string.transformOrFail(s => offsetStrategyLowerMap.get(s.toLowerCase).toRight(s"Invalid AutoOffsetStrategy: $s"), _.toString)
implicit val jsonCodec: JsonCodec[ConsumerConfig] = DeriveJsonCodec.gen
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy