Package com.github.nomisRev.kafka

Types

Link copied to clipboard
enum Acks : Enum<Acks>
Link copied to clipboard
data class AdminSettings(val bootstrapServer: String, props: Properties? = null)

Typed data class for creating a valid Admin instance. The only required parameter is the bootstrapServer, and all other optional parameters can be added using the props parameter.

Link copied to clipboard
enum AutoOffsetReset : Enum<AutoOffsetReset>
Link copied to clipboard
data class ConsumerSettings<K, V>(    val bootstrapServers: String,     val keyDeserializer: Deserializer<K>,     val valueDeserializer: Deserializer<V>,     val groupId: String,     val clientDnsLookup: ClientDnsLookup = ClientDnsLookup.USE_ALL_DNS_IPS,     val sessionTimeOut: Duration = Duration.ofMillis(10000),     val heartbeatInterval: Duration = Duration.ofMillis(3000),     val autoOffsetReset: AutoOffsetReset = AutoOffsetReset.Latest,     val partitionAssignmentStrategy: List<Class<*>> = listOf(RangeAssignor::class.java),     val metadataMaxAge: Long = (5 * 60 * 1000).toLong(),     val enableAutoCommit: Boolean = true,     val autoCommitInterval: Duration = Duration.ofMillis(5000),     val clientId: String = "",     val maxPartitionFetchBytes: Int = DEFAULT_MAX_PARTITION_FETCH_BYTES,     val sendBuffer: Int = 128 * 1024,     val receiveBuffer: Int = 64 * 1024,     val fetchMinBytes: Int = 1,     val fetchMaxBytes: Int = ConsumerConfig.DEFAULT_FETCH_MAX_BYTES,     val fetchMaxWait: Duration = Duration.ofMillis(500),     val reconnectBackoff: Duration = Duration.ofMillis(50L),     val reconnectBackoffMax: Duration = Duration.ofMillis(1000),     val retryBackoff: Duration = Duration.ofMillis(100),     val checkCrcs: Boolean = true,     val metricsSampleWindow: Duration = Duration.ofMillis(30000),     val metricsNumSamples: Int = 2,     val metricsRecordingLevel: Sensor.RecordingLevel = Sensor.RecordingLevel.INFO,     val metricsReporterClasses: List<Class<*>> = emptyList(),     val requestTimeout: Duration = Duration.ofMillis(30000),     val defaultApiTimeout: Duration = Duration.ofMillis(60 * 1000),     val connectionsMaxIdle: Duration = Duration.ofMillis(9 * 60 * 1000),     val interceptorClasses: List<Class<*>> = emptyList(),     val maxPollRecords: Int = 500,     val maxPollInterval: Duration = Duration.ofMillis(300000),     val excludeInternalTopics: Boolean = ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS,     properties: Properties? = null)

Default values taken from org.apache.kafka.clients.consumer.ConsumerConfig

Link copied to clipboard
object NothingDeserializer : Deserializer<Nothing>

A Deserializer for Nothing, this way we signal in a typed way that Key is not used for a certain topic.

Link copied to clipboard
object NothingSerializer : Serializer<Nothing>

A Serializer for Nothing, this way we signal in a typed way that Key is not used for a certain topic.

Link copied to clipboard
data class ProducerSettings<K, V>(    val bootstrapServers: String,     val keyDeserializer: Serializer<K>,     val valueDeserializer: Serializer<V>,     val acks: Acks = Acks.One)

Functions

Link copied to clipboard
fun Admin(settings: AdminSettings): Admin
Link copied to clipboard
fun <T> KafkaFuture<T>.asDeferred(): Deferred<T>

Converts this KafkaFuture to an instance of Deferred.

Link copied to clipboard
suspend fun CreateTopicsResult.await()

Await all CreateTopicsResult in a suspending way.

suspend fun DeleteTopicsResult.await()

Await all DeleteTopicsResult in a suspending way.

suspend fun <T> KafkaFuture<T>.await(): T

Await a KafkaFuture in a suspending way. Code inspired by KotlinX Coroutines JDK8

Link copied to clipboard
suspend fun Admin.createTopic(topic: NewTopic, option: CreateTopicsOptions = CreateTopicsOptions())

Extension method on Admin to create a single Topic in a suspending way.

Link copied to clipboard
suspend fun Admin.deleteTopic(name: String, options: DeleteTopicsOptions = DeleteTopicsOptions())

Extension method on Admin to delete a single Topic in a suspending way.

Link copied to clipboard
suspend fun Admin.describeTopic(name: String, options: DescribeTopicsOptions = DescribeTopicsOptions()): TopicDescription?

Extension method to describe a single Topic

Link copied to clipboard
fun <A, B> Serializer<A>.imap(f: (B) -> A): Serializer<B>
Link copied to clipboard
fun <K, V> kafkaConsumer(settings: ConsumerSettings<K, V>): Flow<KafkaConsumer<K, V>>