2026-02-09 15:49:50 +05:30
|
|
|
"""RQ queue and Redis connection helpers for background workers."""
|
|
|
|
|
|
2026-02-04 02:28:51 +05:30
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from redis import Redis
|
|
|
|
|
from rq import Queue
|
|
|
|
|
|
|
|
|
|
from app.core.config import settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_redis() -> Redis:
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Create a Redis client from configured settings."""
|
2026-02-04 02:28:51 +05:30
|
|
|
return Redis.from_url(settings.redis_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_queue(name: str) -> Queue:
|
2026-02-09 15:49:50 +05:30
|
|
|
"""Return an RQ queue bound to the configured Redis connection."""
|
2026-02-04 02:28:51 +05:30
|
|
|
return Queue(name, connection=get_redis())
|