Python · Redis Streams
Publish and consume with consumer groups, retries, a dead-letter queue and middleware. A few lines of plain Python, and your messages find their way downhill.
pip install rillkitTwo files, one stream
No schemas to register and no consumer loop to write. Name a stream and a group, decorate a function, call run.
from rillkit import Broker
broker = Broker.from_env()
broker.publish("orders", {"id": 1, "total": 42.5})from rillkit import Broker, Stream
broker = Broker.from_env()
@broker.subscribe(Stream("orders", group="workers"))
def handle(order: dict):
print("charging", order["id"])
broker.run()What you get
Redis Streams give you the channel. rillkit digs the rest of the bed.
Groups are created for you, every worker gets its own consumer name, and entries stuck with a crashed worker are claimed back once they sit idle.
A failing message comes back after an exponential backoff, up to max_retries. Nothing vanishes quietly.
When retries run out, or you reject it, the entry moves to a DLQ stream along with the error, the original id, the group and the delivery count. replay_dlq() sends it back.
Decide what happens when a handler finishes. The default retries on error. nack() retries, reject() skips straight to the DLQ.
NACK_ON_ERRORACK_ALWAYSACK_FIRSTMANUALWrap receiving, handling, publishing and cleanup. Idempotent ships in the box to skip duplicate deliveries.
on_startup, after_startup, on_shutdown and after_shutdown, as plain decorators.
Handlers receive decoded JSON as a dict. Annotate the parameter with a Pydantic model and it is validated for you.
SIGINT and SIGTERM let in-flight messages finish. Live workers publish a heartbeat you can read with active_workers().
One JSON string in the data field of an ordinary stream entry. Anything that speaks Redis can read it or write it.
How it flows
Downhill from publish to handler, then one of three outcomes. None of them is "lost".
Install it, point it at Redis, and have a worker running before your coffee cools.
pip install rillkit