booblik
Wiki

dev/publisher

Generated page

Model gemma-mtp, commit ef58254ca7be, 2026-08-16, sources: 2. Edit the code or the hand-written documentation instead.

Diagram

PublisherConfig

Configuration parameters for broker connection, topic names, and simulation intervals via environment variables, as defined in Main.kt:177-200.

VariableEnvironment VariableDefault Value
brokerHostBOOBLIK_HOST127.0.0.1
brokerPortBOOBLIK_PORT9092
topicBOOBLIK_TOPICevents
intervalMillisPUBLISH_INTERVAL_MILLIS1000
usersPUBLISH_USERS9
httpPortHTTP_PORT8080
tasksTopicBOOBLIK_TASKS_TOPICnull
taskIntervalMillisTASK_INTERVAL_MILLIS700

openConnection

The retry mechanism used to establish a connection to the broker, ensuring the publisher waits for the broker to be ready, implemented in Main.kt:76-86.

publishForever

The main event loop that simulates user activity by hashing user keys to specific partitions and sending JSON payloads, found in Main.kt:88-108.

publishTasks

A secondary loop that sends tasks to a specific topic using a fixed partition to simulate a work queue, located in Main.kt:111-126.

Stats

Real-time monitoring of sent messages, partition distribution, last offsets, and task counts, managed by the Stats class in Main.kt:131-165.

embeddedServer

The HTTP interface providing health checks and JSON-serialized statistics via Ktor, initialized in Main.kt:58-64.

Key files

FileLinesWhat is there
…/publisher/build.gradle.kts1-7Dependencies for the client, Ktor server, and serialization.
…/publisher/Main.kt35-66The main entry point that orchestrates the connection, producers, and the server.

Behaviour that Surprises

  • The publishForever function uses topic.partitionFor(key) to determine the partition before sending, which is a stable pure function of the key, unlike round-robin partitioners that might advance a counter (Main.kt:97-101).
  • The publishTasks function explicitly uses PartitionId(0) to ensure all tasks go into a single partition, preventing the splitting that would occur if it used a keyed partitioner (Main.kt:120-122).
  • The openConnection function uses an infinite while(true) loop to retry connection attempts until the broker is reachable, preventing startup race conditions (Main.kt:78-84).

On this page