Skip to main content

FastStream broker integration for Redis-backed distributed timer scheduling

Project description

faststream-redis-timers

Supported versions downloads

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faststream_redis_timers-0.1.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

faststream_redis_timers-0.1.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file faststream_redis_timers-0.1.1.tar.gz.

File metadata

  • Download URL: faststream_redis_timers-0.1.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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

Hashes for faststream_redis_timers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9ca724243132eb5823cc128b505d37c2fbf59f4faf2f7979cec93b69c805b691
MD5 de396fc048978845c482825e5cdc80e9
BLAKE2b-256 135cc5bb925dc6de87b92389461502503d1cefa6e0e8ec75fd16dca1ab1db5d4

See more details on using hashes here.

File details

Details for the file faststream_redis_timers-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: faststream_redis_timers-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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

Hashes for faststream_redis_timers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56fbcab9f1bc1120417506195bf61358fb04a0cfdcc3736f03c618f47a3b97af
MD5 cf0c4f18d2e7507e39aa54ee1309c21e
BLAKE2b-256 fc74d4964906e8e1637e9d42470692911c25865e9aa6b6604749135a05384857

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page