FastStream broker integration for Redis-backed distributed timer scheduling
Project description
faststream-redis-timers
faststream-redis-timers is a FastStream broker integration for Redis-backed distributed timer scheduling.
Schedule messages to be delivered to subscribers at a future point in time — reliably, with distributed locking so no timer fires twice.
from datetime import timedelta
from faststream import FastStream
from faststream_redis_timers import TimersBroker
from redis.asyncio import Redis
client = Redis.from_url("redis://localhost:6379")
broker = TimersBroker(client)
app = FastStream(broker)
@broker.subscriber("invoices")
async def handle_invoice(invoice_id: str) -> None:
print(f"Invoice {invoice_id} is due!")
@app.after_startup
async def schedule() -> None:
await broker.publish(
"INV-001",
topic="invoices",
activate_in=timedelta(days=30),
)
How it works
Timers are stored in Redis as two structures:
- A sorted set (
timers_timeline) with the activation timestamp as score - A hash (
timers_payloads) with the serialized message body
A polling loop checks for due timers and delivers each one exactly once using a distributed Redis lock, making it safe to run multiple instances simultaneously.
📚 Documentation
📦 PyPi
📝 License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file faststream_redis_timers-0.0.2.tar.gz.
File metadata
- Download URL: faststream_redis_timers-0.0.2.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
319177110ad065a6029eb7df93c84e419abe98432b192444f735672f93befc65
|
|
| MD5 |
0f1fad9ce1a950ea20aa6a531ffbecc8
|
|
| BLAKE2b-256 |
9e013801119f3b72fd3bab0922f7790ae99ba3ffa001d638773d3ae10d96ee7f
|
File details
Details for the file faststream_redis_timers-0.0.2-py3-none-any.whl.
File metadata
- Download URL: faststream_redis_timers-0.0.2-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d0c97f14f4449b4f1b3ced7b2ceb7716ae5bc53990b24940cf9f10feedc383e
|
|
| MD5 |
bb582486a2f54ac1e72a3179e0a9d044
|
|
| BLAKE2b-256 |
2d5faa6234951ef76b314f5754a47b3f1283c86dc49512c90904b5c04a1ff673
|