com.github.thake.kafka.avro4k.serializer.Avro4kSerde.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of avro4k-kafka-serializer Show documentation
Show all versions of avro4k-kafka-serializer Show documentation
Provides Kafka SerDes and Serializer / Deserializer implementations for avro4k
package com.github.thake.kafka.avro4k.serializer
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
import org.apache.kafka.common.serialization.Deserializer
import org.apache.kafka.common.serialization.Serde
import org.apache.kafka.common.serialization.Serdes
import org.apache.kafka.common.serialization.Serializer
class Avro4kSerde(client: SchemaRegistryClient? = null) : Serde {
@Suppress("UNCHECKED_CAST")
private val inner: Serde = Serdes.serdeFrom(
KafkaAvro4kSerializer(client) as Serializer,
KafkaAvro4kDeserializer(client) as Deserializer
)
override fun serializer(): Serializer {
return inner.serializer()
}
override fun deserializer(): Deserializer {
return inner.deserializer()
}
override fun configure(configs: Map?, isSerdeForRecordKeys: Boolean) {
inner.serializer().configure(configs, isSerdeForRecordKeys)
inner.deserializer().configure(configs, isSerdeForRecordKeys)
}
override fun close() {
inner.serializer().close()
inner.deserializer().close()
}
}