KafkaTopicAdmin

class KafkaTopicAdmin(admin: Admin, replicationFactor: Short? = null, configs: Map<String, String> = emptyMap(), visibleWithin: Duration = DEFAULT_VISIBLE_WITHIN, dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, closeTimeout: Duration = KafkaOptions.CLOSE_TIMEOUT) : TopicAdmin, AutoCloseable

The TopicAdmin over a Kafka admin client, made by create from KafkaOptions:

  • partitions describes the topics, a topic the broker does not know left out; it never creates one.

  • create creates the missing topics with replicationFactor (the broker's default.replication.factor when null) and the topic configs (retention.ms, min.insync.replicas, ...); a topic that exists already is left as it is. It then waits, at most visibleWithin, until every topic can be described, as metadata reaches the brokers a moment after the controller created it.

  • durability reads what a topic's writes survive: its replication factor and its min.insync.replicas, which an acks=all producer's acknowledgement rests on.

The admin's blocking futures are awaited on virtual threads; Kafka being unreachable, or refusing the node's credentials, fails a call as a me.ahoo.wow.spi.transport.TransportUnavailableException (KafkaFailures). close closes the admin client, waiting at most closeTimeout (KafkaOptions.CLOSE_TIMEOUT) for its calls in flight; past it, the client fails them, and a warning says so.

Constructors

Link copied to clipboard
constructor(admin: Admin, replicationFactor: Short? = null, configs: Map<String, String> = emptyMap(), visibleWithin: Duration = DEFAULT_VISIBLE_WITHIN, dispatcher: CoroutineDispatcher = VirtualThreads.dispatcher, closeTimeout: Duration = KafkaOptions.CLOSE_TIMEOUT)

Types

Link copied to clipboard

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun create(topics: Map<String, Int>)
Link copied to clipboard
open suspend override fun partitions(topics: Set<String>): Map<String, Int>
Link copied to clipboard
suspend fun topicId(topic: String): String?

The id the broker gave topic when it was created (KIP-516), another once the topic is deleted and created again; null from a broker that keeps none (the zero id). A topic the broker does not know fails, as a read of it does.