booblik-native
Generated page
Model gemma-mtp, commit ef58254ca7be, 2026-08-16, sources: 5. Edit the code or the hand-written documentation instead.
Diagram
BooblikConnection
The core connection to a broker over a blocking POSIX socket, managing correlation IDs and frame decoding (booblik-native/src/nativeMain/kotlin/ru/workinprogress/booblik/native/Connection.kt:30-35, 158-172). It ensures that responses are matched to the correct requests via correlation IDs (Connection.kt:34-35) and handles the decoding of protocol frames (Connection.kt:158-172).
More: BooblikConnection
Socket
Low-level POSIX socket implementation providing blocking read and write operations (booblik-native/src/nativeMain/kotlin/ru/workinprogress/booblik/native/Socket.kt:105-143, 146-147). It uses getaddrinfo to resolve hostnames and handles the raw byte transfer via send and recv (Socket.kt:60-70).
More: Socket
Producer
An accumulator that batches records by partition and uses a single-threaded dispatcher to manage asynchronous sending (Producer.kt:80-177). It uses a mailbox to receive commands and a runLoop to manage the timing of batch flushes (Producer.kt:81-177).
More: Producer
Consumer
A blocking reader for a specific topic and partition, managing position and high watermark tracking (Consumer.kt:56-143). It provides a Sequence of records by repeatedly calling poll (Consumer.kt:135-140).
Topic
A high-level handle for a topic that provides partition selection via round-robin or key-based partitioning (Connection.kt:176-197). It allows users to find the correct partition for a given key using a partitioner (Connection.kt:190-197).
Key files
| File | Lines | What is there |
|---|---|---|
…/native/Socket.kt | 42-83 | The Socket companion object containing the connect logic. |
…/native/Consumer.kt | 56-143 | The Consumer class implementation. |
…/native/Producer.kt | 75-275 | The Producer class and its internal Command and Batch structures. |
…/native/Connection.kt | 30-207 | The BooblikConnection and Topic classes. |
Public API
| What | Where | Why |
|---|---|---|
Consumer | Consumer.kt:56 | To read records from a specific topic and partition. |
Producer | Producer.kt:75 | To accumulate and send records in batches. |
BooblikConnection | Connection.kt:30 | To manage the underlying socket and protocol communication. |
Topic | Connection.kt:176 | To interact with a specific topic and its partitions. |
Behaviour that surprises
- The
Produceruses anewSingleThreadContextbecauseDispatchers.IOisinternalon Kotlin/Native, meaning the producer must own its own thread to avoid blocking core-limited dispatchers (Producer.kt:80). - The
Consumer.pollfunction advances thepositiononly after whole records are fetched; if a response is truncated due tomaxBytes, the partial tail is dropped and the next poll starts from the beginning of that record (Consumer.kt:105-108). BooblikConnection.producereturnsnullwhenAckPolicy.NONEis used, as no offset is available to report (Connection.kt:59).