Spaces:
Sleeping
Sleeping
File size: 1,079 Bytes
0122e2f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/bin/bash
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
|