Skip to content

Examples ​

Every example here is a complete script that was run against a real Redis, and the output shown is what it printed. To run one yourself, change the Redis URL to match your setup and pip install rillkit (plus "rillkit[pydantic]" where noted).

Most scripts use start() and stop() with a short sleep so they finish by themselves. In a real service you would call broker.run() instead (see Lifecycle), and you would use the default block_ms and claim_idle_ms. The scripts use short values so the retry behaviour is visible in seconds.

ExampleShows
Basic workerthe smallest useful consumer, with the Message object
Two-stage pipeline@subscribe plus @publisher: extraction, then feature engineering
Pydantic modelstyped handlers and validation failures in the DLQ
Retries and DLQflaky and broken messages, dead letters, replay_dlq
Reject vs nacknack() to retry, reject() to skip retries and dead-letter
Manual ackAckPolicy.MANUAL with ack() and nack()
Timing and idempotencya timing middleware and Idempotent
Multiple workersseveral consumers sharing a group, active_workers
Graceful shutdownSIGTERM, systemd and Docker
FastAPI publisherpublishing from a web endpoint
Migrating from redis-pya hand-rolled XREADGROUP loop, before and after

The examples use stream names like orders, jobs and tasks. Use your own names, and a separate Redis database while experimenting.

RillKit is released under the MIT License.