hello-stream · single-node Redpanda + Python four-line discipline
Greenfield producer/consumer that demonstrates idempotence + acks=all + manual commit + read_committed.
services:
redpanda:
image: redpandadata/redpanda:v24.3.1
command: [redpanda, start, --smp=1, --memory=1G, --overprovisioned, --node-id=0,
--kafka-addr=PLAINTEXT://0.0.0.0:9092,
--advertise-kafka-addr=PLAINTEXT://redpanda:9092]
healthcheck:
test: ["CMD-SHELL", "rpk cluster info -X brokers=redpanda:9092 >/dev/null"]
interval: 5s
retries: 12
ports: ["9092:9092", "9644:9644"]
app:
image: python:3.11-slim
working_dir: /app
depends_on:
redpanda: { condition: service_healthy }
volumes: ["./src:/app:ro"]
environment:
BOOTSTRAP: redpanda:9092
command: >-
bash -c "pip install -q confluent-kafka==2.6.0 &&
python produce_consume.py"
Drop into any new microservice that needs to publish or consume events. Replace localhost:9092 with your bootstrap.servers, add SASL/SSL config from your secrets manager, and you have the production shape on day one. The 'four-line discipline' (idempotent + acks=all + manual commit + read_committed) is the producer/consumer review checklist Snap engineers paste into PRs.
hello-stream · single-node Redpanda + Python four-line discipline
Greenfield producer/consumer that demonstrates idempotence + acks=all + manual commit + read_committed.
services:
redpanda:
image: redpandadata/redpanda:v24.3.1
command: [redpanda, start, --smp=1, --memory=1G, --overprovisioned, --node-id=0,
--kafka-addr=PLAINTEXT://0.0.0.0:9092,
--advertise-kafka-addr=PLAINTEXT://redpanda:9092]
healthcheck:
test: ["CMD-SHELL", "rpk cluster info -X brokers=redpanda:9092 >/dev/null"]
interval: 5s
retries: 12
ports: ["9092:9092", "9644:9644"]
app:
image: python:3.11-slim
working_dir: /app
depends_on:
redpanda: { condition: service_healthy }
volumes: ["./src:/app:ro"]
environment:
BOOTSTRAP: redpanda:9092
command: >-
bash -c "pip install -q confluent-kafka==2.6.0 &&
python produce_consume.py"
Drop into any new microservice that needs to publish or consume events. Replace localhost:9092 with your bootstrap.servers, add SASL/SSL config from your secrets manager, and you have the production shape on day one. The 'four-line discipline' (idempotent + acks=all + manual commit + read_committed) is the producer/consumer review checklist Snap engineers paste into PRs.