How yukaz0/pocketkafka works
PocketKafka is a single-process Kafka-compatible broker with a Go client SDK, admin CLI, embedded control center, schema registry, and REST/MQTT gateways. The main workflow is a producer or gateway sending Kafka-protocol requests to the broker, which dispatches them to storage or group coordination; consumers fetch records and commit offsets. The graph also preserves documented monitoring, security, compaction, and tiered-storage capabilities. Source excerpts show key wiring; several branches are documented in the README or represented by their exact enclosing directory because their implementation was not sampled.
Main entry points: store.go Commit Log · handler.go Kafka API Handlers · web Control Center · client.go Go Client SDK
Components 27
Broker Runtime
- Kafka Listener
internal/server/server.go - Request Dispatch
internal/handler/dispatch.go - Kafka API Handlers
internal/handler/handler.go - Protocol Codec
pkg/protocol
Data And Coordination
- Commit Log
internal/storage/store.go - Partitions
internal/storage/partition.go - Group Coordination
internal/coordinator/group.go - Committed Offsets
internal/coordinator/offset_store.go
Clients And Gateways
- Go Client SDK
pkg/client/client.go - Consumer Group SDK
pkg/client/consumer_group.go - Admin CLI
cmd/kctl/main.go - REST Gateway
internal/gateway/rest.go - MQTT Bridge
internal/gateway/mqtt.go
Operations And Security
- Control Center
internal/web - Web Authentication
internal/web/auth.go - Authorization
internal/authz/store.go - Prometheus Metrics
internal/metrics/metrics.go
Registry And Tiering
- Schema Registry
internal/schemaregistry/schema_registry.go - Registry Persistence
internal/schemaregistry/storage.go - Log Compaction
internal/storage/compaction.go - S3 Tiered Storage
internal/tier/s3.go
Other components
- Producers
- Consumers
- MQTT Devices
- HTTP Applications
- Operator
- S3-Compatible Storage
Connections 29
- Producers → Go Client SDK: send messages
README.md - Consumers → Consumer Group SDK: consume messages
README.md - Consumer Group SDK → Go Client SDK: uses client
pkg/client/consumer_group.go - Admin CLI → Go Client SDK: issues commands
cmd/kctl/main.go - Go Client SDK → Kafka Listener: sends Kafka frames
README.md - Kafka Listener → Request Dispatch: dispatches requests
internal/server/server.go - Request Dispatch → Kafka API Handlers: routes API calls
internal/handler/dispatch.go - Kafka API Handlers → Protocol Codec: decodes and encodes
internal/handler/handler.go - Kafka Listener → Protocol Codec: reads and writes frames
internal/server/server.go - Kafka API Handlers → Commit Log: reads and appends
internal/handler/handler.go - Kafka API Handlers → Group Coordination: coordinates groups
internal/handler/handler.go - Group Coordination → Committed Offsets: persists offsets
internal/coordinator/group.go - Commit Log → Partitions: manages partitions
- HTTP Applications → REST Gateway: publishes and consumes
README.md - REST Gateway → Commit Log: reads and writes records
internal/gateway/rest.go - MQTT Devices → MQTT Bridge: publishes and subscribes
README.md - MQTT Bridge → Commit Log: bridges records
internal/gateway/mqtt.go - MQTT Bridge → Authorization: checks permissions
internal/gateway/mqtt.go - Operator → Control Center: operates broker
README.md - Control Center → Group Coordination: shows group state
internal/web/monitor.go - Control Center → Commit Log: shows broker health
internal/web/monitor.go - Control Center → Web Authentication: authenticates requests
internal/web/auth.go - Web Authentication → Authorization: uses principals
- Control Center → Prometheus Metrics: exposes monitoring
README.md - Admin CLI → Schema Registry: manages schemas
README.md - Schema Registry → Registry Persistence: loads and saves
internal/schemaregistry/storage.go - Kafka API Handlers → Log Compaction: configures compaction
internal/handler/handler.go - Commit Log → S3 Tiered Storage: uses tiered storage
README.md - S3 Tiered Storage → S3-Compatible Storage: stores segments
README.md