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.0.3.tar.gz (10.1 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.0.3-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: faststream_redis_timers-0.0.3.tar.gz
  • Upload date:
  • Size: 10.1 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.0.3.tar.gz
Algorithm Hash digest
SHA256 fcfab7bc300fa3bae0eeff80609f5af553907ab3747b07306e391429b3bd2fc0
MD5 5f7162bbda0d6f9e9fef17d9b668195c
BLAKE2b-256 a90ec03c61c908ee6afdea95e37cb0df8deb4ea77afd1d94bc225186eb3141c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: faststream_redis_timers-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 18.7 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5c5ca3a969619c50c5dcd3be4667c0c0a5e64be6d6fa9435780899a39c7c84c0
MD5 ab5c717c80ce7309b6fbf517b7808a1f
BLAKE2b-256 ec3263308a47436d9b2146a2b4c613e5541586b30e155a23eb657970858ab096

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