Skip to main content

Sinks

Sinks are destinations for join and window results. LiteJoin evaluates your SQL queries and forwards matching results to one or more configured sinks.

HTTP Webhook

Sends results as JSON POST requests to a URL.
sinks:
  - type: http
    name: webhook-out
    config:
      url: "http://localhost:9000/webhook"
      timeout: "30s"
FieldTypeDefaultDescription
urlstringrequiredWebhook URL to POST results to.
timeoutduration30sRequest timeout.
Results are sent as JSON in the request body.

Kafka

Produces results as messages to a Kafka topic.
sinks:
  - type: kafka
    name: kafka-out
    config:
      brokers: "localhost:9092"
      topic: "joined-events"
FieldTypeDefaultDescription
brokersstringrequiredComma-separated broker addresses.
topicstringrequiredTarget Kafka topic.

SSE (Server-Sent Events)

Streams results to browser clients via Server-Sent Events. Ideal for real-time dashboards and UIs.
sinks:
  - type: sse
    name: dashboard
    config:
      addr: ":9100"
FieldTypeDefaultDescription
addrstringrequiredAddress to listen on.

Endpoints

The SSE sink exposes three HTTP endpoints:
EndpointMethodDescription
/subscribeGETOpens an SSE stream. Use ?join=name to filter by join or ?join=* for all.
/snapshotGETReturns a JSON snapshot of current results. See Snapshot API.
/healthGETHealth check — returns {"status": "ok"}.

Browser Example

const es = new EventSource('http://localhost:9100/subscribe?join=*');

es.addEventListener('join_result', (event) => {
  const result = JSON.parse(event.data);
  console.log(result.query, result.key, result.rows);
});

Replay on Connect

Add ?replay=true to receive a snapshot of current results as SSE events before switching to live streaming:
const es = new EventSource('http://localhost:9100/subscribe?join=*&replay=true');
Replay events include "_replay": true so your client can distinguish initial state from live updates.

SQLite

Writes results to a local SQLite database for querying by external apps.
sinks:
  - type: sqlite
    name: local-db
    config:
      path: "./output/results.db"
FieldTypeDefaultDescription
pathstringrequiredPath to the SQLite database file.

Routing Joins to Sinks

Each join or window specifies its target sink by name:
joins:
  - name: order-enrichment
    query: |
      SELECT ...
    sink: webhook-out    # ← references the sink name

sinks:
  - type: http
    name: webhook-out    # ← matched by name
    config:
      url: "http://example.com/webhook"
Multiple joins can route to the same sink, and you can configure multiple sinks of different types.