Skip to content

Commit

Permalink
add namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Dec 17, 2024
1 parent 77e87de commit d148171
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/integrations/prefect-redis/prefect_redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
)


class RedisSettings(PrefectBaseSettings):
model_config = _build_settings_config(("redis",), frozen=True)
class RedisMessagingSettings(PrefectBaseSettings):
model_config = _build_settings_config(
(
"redis",
"messaging",
),
frozen=True,
)

host: str = Field(default="localhost")
port: int = Field(default=6379)
Expand Down Expand Up @@ -98,7 +104,7 @@ def get_async_redis_client(
Returns:
Redis: a Redis client
"""
settings = RedisSettings()
settings = RedisMessagingSettings()

return Redis(
host=host or settings.host,
Expand All @@ -114,7 +120,9 @@ def get_async_redis_client(


@cached
def async_redis_from_settings(settings: RedisSettings, **options: Any) -> Redis:
def async_redis_from_settings(
settings: RedisMessagingSettings, **options: Any
) -> Redis:
options = {
"retry_on_timeout": True,
"decode_responses": True,
Expand Down
6 changes: 3 additions & 3 deletions src/integrations/prefect-redis/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest.mock import MagicMock, patch

from prefect_redis.client import (
RedisSettings,
RedisMessagingSettings,
async_redis_from_settings,
close_all_cached_connections,
get_async_redis_client,
Expand All @@ -11,7 +11,7 @@

def test_redis_settings_defaults():
"""Test that RedisSettings has expected defaults"""
settings = RedisSettings()
settings = RedisMessagingSettings()
assert settings.host == "localhost"
assert settings.port == 6379
assert settings.db == 0
Expand Down Expand Up @@ -50,7 +50,7 @@ async def test_get_async_redis_client_custom_params():

async def test_async_redis_from_settings():
"""Test creating Redis client from settings object"""
settings = RedisSettings(
settings = RedisMessagingSettings(
host="settings.host",
port=6381,
username="settings_user",
Expand Down

0 comments on commit d148171

Please sign in to comment.