import os
import redis
from rq import Queue


def get_redis_url() -> str:
    # Default to local Redis service name in compose network
    return os.getenv("REDIS_URL", "redis://redis:6379/0")


def get_queue(name: str = "conversions") -> Queue:
    conn = redis.from_url(get_redis_url())
    # 10 minutes default
    return Queue(name, connection=conn, default_timeout=600)
