"""Async Redis client factory. Used for rate-limiting and future sessions. NOT a job queue — RabbitMQ owns that. """ from __future__ import annotations from typing import Any def get_redis_client(redis_url: str) -> Any: """Create a new async Redis client from a Redis DSN. Callers own the connection lifecycle. The api creates one client at startup and stores it in app.state.redis. Maintenance notifications are disabled: they are a Redis Cloud feature and self-hosted/Valkey servers reject ``CLIENT MAINT_NOTIFICATIONS`` with an ``unknown subcommand`` error, spamming debug logs. """ from redis.asyncio import Redis as AsyncRedis from redis.maint_notifications import MaintNotificationsConfig maint_config = MaintNotificationsConfig(enabled=False) return AsyncRedis.from_url( redis_url, decode_responses=True, maint_notifications_config=maint_config, )