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

com.github.thake.kafka.avro4k.serializer.Avro4kSerde.kt Maven / Gradle / Ivy

There is a newer version: 0.14.0
Show newest version
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()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy