Kafka Templates
Four Kafka patterns on cosmonic:kafka@0.5.0, one per delivery shape. Each is a self-contained project with source, a pinned WIT lockfile, and manifests for Cosmonic and Kubernetes, pointing at prebuilt components published from the repository.
Kafka clients are binding-scoped capabilities: the broker address, credentials, consumer group, and topic grant live in the workload's cosmonic:kafka entry under hostInterfaces, and the component cannot supply or override them at runtime. It therefore cannot redirect itself to another broker or substitute another credential.
Repository: cosmonic-labs/awesome-cosmonic/components/kafka
Languages: Rust
Interfaces: cosmonic:kafka/{handler,producer,consumer,transaction}
Which pattern do I want?
| Template | Shape | Delivery guarantee | Use when… |
|---|---|---|---|
| kafka-handler-consumer | Host pushes partition-ordered batches to elastic component instances | at-least-once; dead-letter on permanent errors | Serverless event processing, including consume→transform→produce. The recommended starting point |
| http-kafka-producer | HTTP request in, Kafka record out | broker ack per record | An API, webhook or UI event needs to publish records; ingest gateways |
| kafka-pull-service | Long-running service owning a pull-consumer session | at-least-once; your own dead-letter routing | You need assign, pause, seek, rebalance events, or explicit commits |
| kafka-transactional | Pull service plus transactions: outputs and input offsets commit atomically | exactly-once read-process-write | Money, inventory, dedup-sensitive enrichment, where a replayed batch is unacceptable |
The host keeps consumer-group membership stable while component instances scale with assigned partition work and can return to zero when idle. Growing the component pool does not add group members or trigger a rebalance; increasing workload replicas does.
Start from one
wash new https://github.com/cosmonic-labs/awesome-cosmonic \
--subfolder components/kafka/rust/kafka-handler-consumerRust only. cosmonic:kafka@0.5.0 declares every function async func, which needs a toolchain that can bind the WASI p3 async ABI.
Secrets
config is for plain values, configFrom pulls a ConfigMap, and secretFrom pulls a Secret. The three merge in that order, so a password reaches the client without appearing in the manifest. See Component Configuration and Secrets.