Spaces:
Sleeping
Sleeping
| set -euo pipefail | |
| RPK="rpk --brokers 127.0.0.1:9092" | |
| # ββ Edit this array to define your topics ββββββββββββββββββββββββββββββββββββ | |
| # Format: "topic-name:partitions" | |
| TOPICS=( | |
| "events:4" | |
| "raw-data:4" | |
| "processed:4" | |
| "dead-letter:1" | |
| ) | |
| RETENTION_MS=3600000 # 1 hour β consume and store yourself | |
| RETENTION_BYTES=536870912 # 512MB per partition max | |
| for entry in "${TOPICS[@]}"; do | |
| IFS=':' read -r name partitions <<< "$entry" | |
| if $RPK topic list 2>/dev/null | grep -q "^${name}"; then | |
| echo " β© ${name} already exists" | |
| continue | |
| fi | |
| $RPK topic create "$name" \ | |
| --partitions "$partitions" \ | |
| --replicas 1 \ | |
| --topic-config "retention.ms=${RETENTION_MS}" \ | |
| --topic-config "retention.bytes=${RETENTION_BYTES}" \ | |
| --topic-config "cleanup.policy=delete" \ | |
| --topic-config "compression.type=snappy" | |
| echo " β ${name} (${partitions} partitions)" | |
| done | |
| echo "Topics ready:" | |
| $RPK topic list | |