brain / src /workers /redis_url.py
Leon4gr45's picture
Upload folder using huggingface_hub (part 3)
a55ea57 verified
Raw History Blame Contribute Delete
463 Bytes
"""Redis connection URL helpers for worker transports."""
from __future__ import annotations
from urllib.parse import quote
def redis_connection_url(
host: str,
port: str | int,
password: str | None,
*,
database: int = 0,
) -> str:
"""Build a Redis URL, percent-encoding credentials when authentication is enabled."""
auth = f":{quote(password, safe='')}@" if password else ""
return f"redis://{auth}{host}:{port}/{database}"