booblik-net
Generated page
Model gemma-mtp, commit f508a4b65b3f, 2026-08-15, sources: 6. Edit the code or the hand-written documentation instead.
Diagram
BooblikServer
The network front end and server lifecycle management. It manages the ServerSocketChannel and orchestrates the startup of either a selector-based or virtual-thread-based transport (BooblikServer.kt:117-147).
More: BooblikServer
Transport
Comparison between SELECTOR and VIRTUAL_THREADS readiness mechanisms.
| Transport | Description |
|---|---|
SELECTOR | Own selector loop, one coroutine per connection (BooblikServer.kt:26-27) |
VIRTUAL_THREADS | Blocking sockets, one virtual thread per connection (BooblikServer.kt:30-33) |
More: Transport
FetchMode
The ZERO_COPY and HEAP strategies for response delivery.
| FetchMode | Description |
|---|---|
ZERO_COPY | sendfile: page cache to socket buffer, never through the JVM (BooblikServer.kt:39) |
HEAP | Read into a heap buffer and write it (BooblikServer.kt:42) |
More: FetchMode
Connection
The abstraction layer for SelectorConnection and BlockingConnection. It defines how data is read, written, and transferred from segments to the socket (Connection.kt:23-53).
SelectorLoop
The NIO readiness engine and the mechanism for queuing interest changes. It uses a dedicated thread to process SelectionKey readiness and handles interest changes via a ConcurrentLinkedQueue to avoid blocking the selector (SelectorLoop.kt:31-40).
Broker
Management of partitions, retention policies, and the partition registry. It is responsible for opening partitions from a directory and applying retention policies (Broker.kt:49-81).
Metrics
Telemetry for network counters, session failures, and partition snapshots. It provides a snapshot function to capture the current state of the broker and its partitions (Metrics.kt:29-145).
Key files
| File | Lines | What is there |
|---|---|---|
…/net/BooblikServer.kt | 45-64 | ServerConfig definition |
…/net/BooblikServer.kt | 67-70 | PartitionHandle definition |
…/net/BooblikServer.kt | 79-107 | PartitionRegistry definition |
…/net/BooblikServer.kt | 117-121 | BooblikServer class declaration |
…/nio/Connection.kt | 23-53 | Connection interface |
…/nio/Connection.kt | 56-97 | SelectorConnection class |
…/nio/Connection.kt | 108-142 | BlockingConnection class |
…/nio/SelectorLoop.kt | 31-40 | SelectorLoop class |
…/net/Broker.kt | 19-28 | BrokerConfig definition |
…/net/Broker.kt | 49-54 | Broker class declaration |
…/net/Metrics.kt | 29-48 | Metrics class declaration |
Public API
| What | Where | Why |
|---|---|---|
ServerConfig | BooblikServer.kt:45 | Configuration for the server transport and fetch modes. |
PartitionHandle | BooblikServer.kt:67 | Holds the log and writer for a specific partition. |
PartitionRegistry | BooblikServer.kt:79 | A registry to find partition handles by topic and ID. |
BooblikServer | BooblikServer.kt:117 | The main server entry point for starting and closing the broker. |
Connection | Connection.kt:23 | Abstraction for reading and writing to a client. |
SelectorConnection | Connection.kt:56 | A non-blocking connection implementation using a SelectorLoop. |
BlockingConnection | Connection.kt:108 | A blocking connection implementation for virtual threads. |
SelectorLoop | SelectorLoop.kt:31 | The engine that manages NIO readiness. |
BrokerConfig | Broker.kt:19 | Configuration for segmenting and retention in the broker. |
Broker | Broker.kt:49 | The high-level broker managing partitions and retention. |
Metrics | Metrics.kt:29 | Provides telemetry and snapshots of broker activity. |
Behaviour that surprises
SelectorLoopuses aConcurrentLinkedQueueto post interest changes because modifyingSelectionKey.interestOpsfrom a thread other than the selector thread can be ineffective or block (SelectorLoop.kt:26-28).BlockingConnection'stransferFrommethod may enter a tight loop ifsegment.transferToreturns zero, as it treats zero as "try again immediately" rather than waiting (Connection.kt:134).BooblikServeruses aSupervisorJobfor its scope so that a failure in a single client session does not crash the entire server (BooblikServer.kt:185-186).