# Kafka

Lightweight, dependency-free Kafka broker emulator speaking the Kafka binary
wire protocol, so the standard `kafkajs` client can connect.

| Key | Value |
|-----|-------|
| Port | 9092 |
| Protocol | Kafka wire protocol (TCP) |
| Size | ~90 KB |
| Startup | fast |

## Default Connection

```
localhost:9092
```

## Supported APIs

| Area | Operations |
|------|-----------|
| Cluster | ApiVersions, Metadata, FindCoordinator |
| Topics | CreateTopics, DeleteTopics, ListTopics (incl. multi-partition) |
| Produce | Produce one or many messages, partition distribution |
| Consume | Fetch from offset, per-partition offset tracking, ListOffsets |
| Groups | JoinGroup, SyncGroup, Heartbeat, LeaveGroup, OffsetCommit/Fetch |

## Usage Examples

```typescript
const instance = await startParallel({ services: [{ name: "kafka" }] });
const port = instance.services.get("kafka").port;

import { Kafka } from "kafkajs";
const kafka = new Kafka({ brokers: [`localhost:${port}`] });

const admin = kafka.admin();
await admin.createTopics({ topics: [{ topic: "events", numPartitions: 3 }] });

const producer = kafka.producer();
await producer.connect();
await producer.send({ topic: "events", messages: [{ value: "hello" }] });

const consumer = kafka.consumer({ groupId: "g1" });
await consumer.subscribe({ topic: "events", fromBeginning: true });
```

## Access via Parlel Sandbox

Kafka uses a binary wire protocol, so `parlel_execute` does not drive it. Inside
a sandbox, open the SSH tunnel shown in the Connect panel and point a native
Kafka client (e.g. `kafkajs`) at `localhost:9092`.

## Surface coverage

This emulator faithfully replicates the API surface most application code and agents exercise. Anything below the supported lines is either an intentional design choice for a fast, zero-cost local emulator (✓ By design) or a candidate for a future release (⟳ Roadmap) — never a silent inaccuracy.

Legend: ✅ fully supported · ◐ accepted (stored, not strictly enforced) · ✓ by design · ⟳ on the roadmap.

| Feature | Status |
|---------|--------|
| Topics / partitions / produce / fetch | Supported |
| Consumer groups (basic) | Supported |
| Transactions / exactly-once | Not supported |
| Compression / SASL / TLS | Not supported |
