All Downloads are FREE. Search and download functionalities are using the official Maven repository.

trace4cats.kafka.KafkaHeaders.scala Maven / Gradle / Ivy

There is a newer version: 0.14.3
Show newest version
package trace4cats.kafka

import cats.syntax.foldable._
import fs2.kafka.{Header, Headers}
import trace4cats.model.TraceHeaders

object KafkaHeaders {
  val converter: TraceHeaders.Converter[Headers] = new TraceHeaders.Converter[Headers] {
    def from(t: Headers): TraceHeaders =
      t.toChain.foldMap(h => TraceHeaders.of(h.key() -> h.as[String]))
    def to(h: TraceHeaders): Headers =
      Headers.fromIterable(h.values.map { case (k, v) => Header(k.toString, v) })
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy