Skip to content

Commit

Permalink
fix: Properly parse the redis server URL string
Browse files Browse the repository at this point in the history
  • Loading branch information
achimnol committed Sep 6, 2023
1 parent d362e59 commit bd97ce8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def read_src_version():


install_requires = [
"aiotools>=1.5.9",
"async_timeout>=3.0.1",
"aiotools>=1.7.0",
"attrs>=21.3.0",
"python-dateutil>=2.8.2",
"msgpack>=1.0.4",
"temporenc>=0.1",
"yarl>=1.8.2",
]

build_requires = [
Expand Down
8 changes: 7 additions & 1 deletion src/callosum/lower/redis_common.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import yarl


def redis_addr_to_url(
value: str | tuple[str, int],
*,
scheme: str = "redis",
) -> str:
match value:
case str():
return f"{scheme}://{value}"
url = yarl.URL(value)
if url.scheme is None:
return str(yarl.URL(value).with_scheme(scheme))
return value
case (host, port):
return f"{scheme}://{host}:{port}"
case _:
Expand Down

0 comments on commit bd97ce8

Please sign in to comment.