booblik-client
Generated page
Model gemma-mtp, commit ef58254ca7be, 2026-08-16, sources: 6. Edit the code or the hand-written documentation instead.
Diagram
BooblikClient
The low-level, blocking, single-socket client for sending raw requests. It provides the most basic interface for sending PRODUCE, FETCH, and METADATA requests directly to a SocketChannel BooblikClient.kt:24-88.
More: BooblikClient
BooblikConnection
The pipelined connection mechanism that manages concurrent requests via a single writer coroutine and a FIFO response queue. It uses an AtomicInteger to manage correlationIds BooblikConnection.kt:71 and ensures that responses are matched to callers in strict order, failing loudly if the broker reorders them BooblikConnection.kt:34-38.
More: BooblikConnection
Producer
The high-level accumulator that batches records by partition and manages the lingerMillis and maxBatchSize logic Producer.kt:21-34. It uses a mailbox to receive Command.Append requests and an internal runLoop to decide when to trigger a deliver call based on the configured ProducerConfig Producer.kt:54-173.
More: Producer
Consumer
The stateful reader that manages the position offset and handles RecordExceedsMaxBytesException during polling Consumer.kt:56-97. It tracks the current position and advances it only past whole records when a poll is successful Consumer.kt:56-97.
ResponseReader
The decoding layer that handles frame reading and checksum verification for FETCH responses. It reads the length-prefixed frames from a SocketChannel and delegates decoding to the protocol module, specifically handling the translation of CorruptRecordException ResponseReader.kt:55-109.
ResponseEncoder
The construction of response frames, specifically the zero-copy header mechanism for FETCH responses. It distinguishes between "promised" bytes (the body to be streamed) and "inline" bytes (the header) to support efficient zero-copy reading ResponseEncoder.kt:15-117.
Key files
| File | Lines | What is there |
|---|---|---|
…/client/BooblikClient.kt | 24-88 | The low-level blocking client implementation. |
…/client/BooblikConnection.kt | 50-241 | The pipelined connection and coroutine-based writer/reader. |
…/client/Producer.kt | 54-264 | The batching producer implementation. |
…/client/Consumer.kt | 56-113 | The stateful consumer implementation. |
…/client/ResponseReader.kt | 55-118 | The response decoding and frame reading logic. |
…/wire/ResponseEncoder.kt | 15-130 | The logic for encoding response frames and headers. |
Public API
| What | Where | Why |
|---|---|---|
BooblikClient | BooblikClient.kt:24 | Low-level client for raw requests. |
BooblikConnection | BooblikConnection.kt:50 | Pipelined connection for concurrent requests. |
Producer | Producer.kt:54 | High-level batching producer. |
ProducerConfig | Producer.kt:21 | Configuration for batching and ack policy. |
Consumer | Consumer.kt:56 | Stateful partition reader. |
ResponseReader | ResponseReader.kt:55 | Object for decoding response frames. |
ResponseEncoder | ResponseEncoder.kt:15 | Object for encoding response frames. |
Behaviour that surprises
- The
Produceruses aselectexpression in itsrunLoopto avoid a specific bug where a cancelledreceivecould drop elements from themailbox, potentially causing callers to wait foreverProducer.kt:154-158. - The
Consumercan throw aRecordExceedsMaxBytesExceptionif a record is larger than themaxByteslimit, which results in a permanent stall if the reader does not increase its limitConsumer.kt:28-36. - The
ResponseEncoderuses a "promised" vs "inline" byte mechanism forfetchHeaderto allow the client to perform zero-copy reads of the response bodyResponseEncoder.kt:39-41.