booblik
Wiki

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

FileLinesWhat is there
…/client/BooblikClient.kt24-88The low-level blocking client implementation.
…/client/BooblikConnection.kt50-241The pipelined connection and coroutine-based writer/reader.
…/client/Producer.kt54-264The batching producer implementation.
…/client/Consumer.kt56-113The stateful consumer implementation.
…/client/ResponseReader.kt55-118The response decoding and frame reading logic.
…/wire/ResponseEncoder.kt15-130The logic for encoding response frames and headers.

Public API

WhatWhereWhy
BooblikClientBooblikClient.kt:24Low-level client for raw requests.
BooblikConnectionBooblikConnection.kt:50Pipelined connection for concurrent requests.
ProducerProducer.kt:54High-level batching producer.
ProducerConfigProducer.kt:21Configuration for batching and ack policy.
ConsumerConsumer.kt:56Stateful partition reader.
ResponseReaderResponseReader.kt:55Object for decoding response frames.
ResponseEncoderResponseEncoder.kt:15Object for encoding response frames.

Behaviour that surprises

  • The Producer uses a select expression in its runLoop to avoid a specific bug where a cancelled receive could drop elements from the mailbox, potentially causing callers to wait forever Producer.kt:154-158.
  • The Consumer can throw a RecordExceedsMaxBytesException if a record is larger than the maxBytes limit, which results in a permanent stall if the reader does not increase its limit Consumer.kt:28-36.
  • The ResponseEncoder uses a "promised" vs "inline" byte mechanism for fetchHeader to allow the client to perform zero-copy reads of the response body ResponseEncoder.kt:39-41.

On this page