[REF-3570] Remove deprecated REDIS_URL syntax (#3892)
This commit is contained in:
parent
cbe532cfc5
commit
43d79d3a24
@ -325,24 +325,19 @@ def parse_redis_url() -> str | dict | None:
|
||||
"""Parse the REDIS_URL in config if applicable.
|
||||
|
||||
Returns:
|
||||
If redis-py syntax, return the URL as it is. Otherwise, return the host/port/db as a dict.
|
||||
If url is non-empty, return the URL as it is.
|
||||
|
||||
Raises:
|
||||
ValueError: If the REDIS_URL is not a supported scheme.
|
||||
"""
|
||||
config = get_config()
|
||||
if not config.redis_url:
|
||||
return None
|
||||
if config.redis_url.startswith(("redis://", "rediss://", "unix://")):
|
||||
return config.redis_url
|
||||
console.deprecate(
|
||||
feature_name="host[:port] style redis urls",
|
||||
reason="redis-py url syntax is now being used",
|
||||
deprecation_version="0.3.6",
|
||||
removal_version="0.6.0",
|
||||
)
|
||||
redis_url, has_port, redis_port = config.redis_url.partition(":")
|
||||
if not has_port:
|
||||
redis_port = 6379
|
||||
console.info(f"Using redis at {config.redis_url}")
|
||||
return dict(host=redis_url, port=int(redis_port), db=0)
|
||||
if not config.redis_url.startswith(("redis://", "rediss://", "unix://")):
|
||||
raise ValueError(
|
||||
"REDIS_URL must start with 'redis://', 'rediss://', or 'unix://'."
|
||||
)
|
||||
return config.redis_url
|
||||
|
||||
|
||||
async def get_redis_status() -> bool | None:
|
||||
|
Loading…
Reference in New Issue
Block a user