InsightsSink

class InsightsSink(url: String, token: String, instanceId: String, batchSize: Int = 200, flushIntervalMs: Long = 250, queueCapacity: Int, failureBackoffMs: Long, maxPostAttempts: Int = 3, healthIntervalMs: Long, journalDir: Path? = null, http: OkHttpClient = OkHttpClient .Builder() .connectTimeout(5, TimeUnit.SECONDS) .readTimeout(5, TimeUnit.SECONDS) .writeTimeout(5, TimeUnit.SECONDS) .build()) : AutoCloseable

Egress to a qkt-insights collector.

The contract that matters: the publishing (engine) thread never blocks and never touches the network. offer only enqueues onto a bounded queue - O(1), no waits. When the queue is full the oldest envelope is dropped and dropped increments.

Without journalDir the sink is best-effort: failed batches are dropped after maxPostAttempts. With journalDir, the drain thread first spools serialized envelopes to disk and advances the journal cursor only after qkt-insights accepts the batch. Collector downtime therefore causes retry/replay, not batch loss.

Constructors

Link copied to clipboard
constructor(url: String, token: String, instanceId: String, batchSize: Int = 200, flushIntervalMs: Long = 250, queueCapacity: Int, failureBackoffMs: Long, maxPostAttempts: Int = 3, healthIntervalMs: Long, journalDir: Path? = null, http: OkHttpClient = OkHttpClient .Builder() .connectTimeout(5, TimeUnit.SECONDS) .readTimeout(5, TimeUnit.SECONDS) .writeTimeout(5, TimeUnit.SECONDS) .build())

Properties

Link copied to clipboard

Envelopes lost from queue shedding or, in best-effort mode, exhausted POST attempts.

Link copied to clipboard

POST attempts that failed (non-2xx or I/O error).

Link copied to clipboard

Envelopes acknowledged by the collector.

Functions

Link copied to clipboard
open override fun close()

Stops the drain thread after a final flush attempt of whatever is queued.

Link copied to clipboard
fun offer(envelope: InsightsEnvelope)

Enqueue an envelope. Never blocks: on a full queue the oldest entry is dropped to make room. Safe to call from the engine thread.