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.0.tar.gz (10.2 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.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: faststream_redis_timers-0.1.0.tar.gz
  • Upload date:
  • Size: 10.2 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.0.tar.gz
Algorithm Hash digest
SHA256 84d6a3b2feabf5ef052a48fc819e3edebf0d89ec0e45340d0a5eeef984caf27e
MD5 f0a53e5af49a73a2b9bbef12c7529f4d
BLAKE2b-256 da79c2376c884266847fd0cd3f4a4869e18bbc94d646ae54d840270fc2b7c8b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faststream_redis_timers-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 363cd6c203b9bb3ec6a5303049393dbdc1d07f010520cf5974a8694a9d376b6b
MD5 e230401da214174a06d61e43d841a896
BLAKE2b-256 4242304fc2ef180983cb0260d8585fd542367396fa32f30abb93e9857ea9174a

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