Basic usage with Task semantics
Basic usage with Task semantics
import { EventLog } from "@anabranch/eventlog"; import { createKafka } from "@anabranch/eventlog-kafka"; const connector = createKafka({ brokers: ["localhost:9092"] }); const log = await EventLog.connect(connector).run(); const eventId = await log.append("users", { action: "created", userId: 123 }).run();
Consuming events as a stream with manual cursor commit
Consuming events as a stream with manual cursor commit
const connector = createKafka({ brokers: ["localhost:9092"], groupId: "processor-1" }); const log = await EventLog.connect(connector).run(); const { successes, errors } = await log .consume("users", "processor-1") .withConcurrency(5) .map(async (batch) => { for (const event of batch.events) { await processEvent(event.data); } await log.commit(batch.topic, batch.consumerGroup, batch.cursor).run(); }) .partition();