booblik
Wiki

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

FileLinesWhat is there
…/native/Socket.kt42-83The Socket companion object containing the connect logic.
…/native/Consumer.kt56-143The Consumer class implementation.
…/native/Producer.kt75-275The Producer class and its internal Command and Batch structures.
…/native/Connection.kt30-207The BooblikConnection and Topic classes.

Public API

WhatWhereWhy
ConsumerConsumer.kt:56To read records from a specific topic and partition.
ProducerProducer.kt:75To accumulate and send records in batches.
BooblikConnectionConnection.kt:30To manage the underlying socket and protocol communication.
TopicConnection.kt:176To interact with a specific topic and its partitions.

Behaviour that surprises

  • The Producer uses a newSingleThreadContext because Dispatchers.IO is internal on Kotlin/Native, meaning the producer must own its own thread to avoid blocking core-limited dispatchers (Producer.kt:80).
  • The Consumer.poll function advances the position only after whole records are fetched; if a response is truncated due to maxBytes, the partial tail is dropped and the next poll starts from the beginning of that record (Consumer.kt:105-108).
  • BooblikConnection.produce returns null when AckPolicy.NONE is used, as no offset is available to report (Connection.kt:59).

On this page