Runtime Connections
Kafka
Archetype: EventBus — routes lifecycle events to Kafka topics, slotted at options.eventBus.
What it does
Publishes Boss events (LoopTransitionedEvent, LoopStartedEvent, LoopCompletedEvent, LearningSignalEmittedEvent) to Kafka topics. Use this for audit pipelines, analytics, and cross-system event triggers.
Quick setup
-
Install
1npm install @loop-engine/adapter-kafka kafkajs -
Create a Kafka-backed
EventBuswithkafkaEventBuskafkaEventBuspublishes loop events to Kafka. Theemitpath is supported at1.0.0-rc.0; thekafkajsclient’sproducer().sendreturn type is slightly wider than the internalKafkaLikestub, so the example below uses a narrowas anyon thekafkainstance.1"cmt">// @no-typecheck2import { Kafka } from "kafkajs";3import { kafkaEventBus } from "@loop-engine/adapter-kafka";4import { createLoopSystem } from "@loop-engine/sdk";56const brokers = ["kafka-1:9092", "kafka-2:9092"];7const connection = new Kafka({ clientId: "loop-engine", brokers });8const events = kafkaEventBus({9 kafka: connection as any,10 topic: "loop-engine.events"11});1213const { engine, eventBus: loopBus } = await createLoopSystem({ loops: [procurementLoop] });14"cmt">// Application wiring: bridge `loopBus` → `events` (or use `events` as the sole bus) per your deployment.15void engine;16void events;17void loopBus;
Configuration reference
| Option | Type | Default | Description |
|---|---|---|---|
| brokers | string[] | required | Kafka broker list |
| topicPrefix | string | loop-engine | Prefix for emitted event topics |
| clientId | string | loop-engine | Kafka client ID |
| ssl | boolean | false | Enable TLS |
| sasl | object | — | SASL credentials and mechanism |
Troubleshooting
- Connection timeout — Check broker addresses and network policy/firewall.
- Authentication error — Validate
saslmechanism/user/secret. - Topic missing — Enable topic auto-create or pre-create topics manually.