Skip to content

Commit

Permalink
Python: Rename ClusterClientConfiguration to GlideClusterClientConfig…
Browse files Browse the repository at this point in the history
…uration (valkey-io#1806)
  • Loading branch information
shohamazon authored and cyip10 committed Jul 4, 2024
1 parent b74c3f0 commit 250d7ed
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 53 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
* Node: Update XREAD to return a Map of Map ([#1494](https://github.com/aws/glide-for-redis/pull/1494))
* Node: Rename RedisClient to GlideClient and RedisClusterClient to GlideClusterClient ([#1670](https://github.com/aws/glide-for-redis/pull/1670))
* Python: Rename RedisClient to GlideClient, RedisClusterClient to GlideClusterClient and BaseRedisClient to BaseClient([#1669](https://github.com/aws/glide-for-redis/pull/1669))
* Python: Rename ClusterClientConfiguration to GlideClusterClientConfiguration ([#1806](https://github.com/aws/glide-for-redis/pull/1806))

## 0.4.1 (2024-02-06)

Expand Down
4 changes: 2 additions & 2 deletions examples/python/client_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379):
# When in Redis is in standalone mode, add address of the primary node,
# and any replicas you'd like to be able to read from.
addresses = [NodeAddress(host, port)]
# Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
# Check `GlideClientConfiguration/GlideClusterClientConfiguration` for additional options.
config = BaseClientConfiguration(
addresses=addresses,
client_name="test_standalone_client",
Expand All @@ -59,7 +59,7 @@ async def test_standalone_client(host: str = "localhost", port: int = 6379):
async def test_cluster_client(host: str = "localhost", port: int = 6379):
# When in Redis is cluster mode, add address of any nodes, and the client will find all nodes in the cluster.
addresses = [NodeAddress(host, port)]
# Check `GlideClientConfiguration/ClusterClientConfiguration` for additional options.
# Check `GlideClientConfiguration/GlideClusterClientConfiguration` for additional options.
config = BaseClientConfiguration(
addresses=addresses,
client_name="test_cluster_client",
Expand Down
4 changes: 2 additions & 2 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ To install GLIDE for Redis using `pip`, follow these steps:

```python:
>>> import asyncio
>>> from glide import ClusterClientConfiguration, NodeAddress, GlideClusterClient
>>> from glide import GlideClusterClientConfiguration, NodeAddress, GlideClusterClient
>>> async def test_cluster_client():
... addresses = [NodeAddress("redis.example.com", 6379)]
... config = ClusterClientConfiguration(addresses)
... config = GlideClusterClientConfiguration(addresses)
... client = await GlideClusterClient.create(config)
... set_result = await client.set("foo", "bar")
... print(f"Set response is {set_result}")
Expand Down
4 changes: 2 additions & 2 deletions python/python/glide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
from glide.config import (
BackoffStrategy,
BaseClientConfiguration,
ClusterClientConfiguration,
GlideClientConfiguration,
GlideClusterClientConfiguration,
NodeAddress,
PeriodicChecksManualInterval,
PeriodicChecksStatus,
Expand Down Expand Up @@ -110,7 +110,7 @@
# Config
"BaseClientConfiguration",
"GlideClientConfiguration",
"ClusterClientConfiguration",
"GlideClusterClientConfiguration",
"BackoffStrategy",
"ReadFrom",
"ServerCredentials",
Expand Down
8 changes: 4 additions & 4 deletions python/python/glide/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def _get_pubsub_callback_and_context(
return None, None


class ClusterClientConfiguration(BaseClientConfiguration):
class GlideClusterClientConfiguration(BaseClientConfiguration):
"""
Represents the configuration settings for a Cluster Glide client.
Expand All @@ -369,7 +369,7 @@ class ClusterClientConfiguration(BaseClientConfiguration):
These checks evaluate changes in the cluster's topology, triggering a slot refresh when detected.
Periodic checks ensure a quick and efficient process by querying a limited number of nodes.
Defaults to PeriodicChecksStatus.ENABLED_DEFAULT_CONFIGS.
pubsub_subscriptions (Optional[ClusterClientConfiguration.PubSubSubscriptions]): Pubsub subscriptions to be used for the client.
pubsub_subscriptions (Optional[GlideClusterClientConfiguration.PubSubSubscriptions]): Pubsub subscriptions to be used for the client.
Will be applied via SUBSCRIBE/PSUBSCRIBE/SSUBSCRIBE commands during connection establishment.
Notes:
Expand All @@ -395,7 +395,7 @@ class PubSubSubscriptions:
"""Describes pubsub configuration for cluster mode client.
Attributes:
channels_and_patterns (Dict[ClusterClientConfiguration.PubSubChannelModes, Set[str]]):
channels_and_patterns (Dict[GlideClusterClientConfiguration.PubSubChannelModes, Set[str]]):
Channels and patterns by modes.
callback (Optional[Callable[[CoreCommands.PubSubMsg, Any], None]]):
Optional callback to accept the incoming messages.
Expand All @@ -404,7 +404,7 @@ class PubSubSubscriptions:
"""

channels_and_patterns: Dict[
ClusterClientConfiguration.PubSubChannelModes, Set[str]
GlideClusterClientConfiguration.PubSubChannelModes, Set[str]
]
callback: Optional[Callable[[CoreCommands.PubSubMsg, Any], None]]
context: Any
Expand Down
6 changes: 3 additions & 3 deletions python/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import pytest
from glide.config import (
ClusterClientConfiguration,
GlideClientConfiguration,
GlideClusterClientConfiguration,
NodeAddress,
ProtocolVersion,
ServerCredentials,
Expand Down Expand Up @@ -224,7 +224,7 @@ async def create_client(
protocol: ProtocolVersion = ProtocolVersion.RESP3,
timeout: Optional[int] = None,
cluster_mode_pubsub: Optional[
ClusterClientConfiguration.PubSubSubscriptions
GlideClusterClientConfiguration.PubSubSubscriptions
] = None,
standalone_mode_pubsub: Optional[
GlideClientConfiguration.PubSubSubscriptions
Expand All @@ -237,7 +237,7 @@ async def create_client(
assert database_id == 0
k = min(3, len(pytest.redis_cluster.nodes_addr))
seed_nodes = random.sample(pytest.redis_cluster.nodes_addr, k=k)
cluster_config = ClusterClientConfiguration(
cluster_config = GlideClusterClientConfiguration(
addresses=seed_nodes if addresses is None else addresses,
use_tls=use_tls,
credentials=credentials,
Expand Down
2 changes: 1 addition & 1 deletion python/python/tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
)
from glide.async_commands.transaction import ClusterTransaction, Transaction
from glide.config import (
ClusterClientConfiguration,
GlideClientConfiguration,
GlideClusterClientConfiguration,
ProtocolVersion,
ServerCredentials,
)
Expand Down
4 changes: 2 additions & 2 deletions python/python/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from glide.config import (
BaseClientConfiguration,
ClusterClientConfiguration,
GlideClusterClientConfiguration,
NodeAddress,
PeriodicChecksManualInterval,
PeriodicChecksStatus,
Expand Down Expand Up @@ -38,7 +38,7 @@ def test_convert_to_protobuf():


def test_periodic_checks_interval_to_protobuf():
config = ClusterClientConfiguration(
config = GlideClusterClientConfiguration(
[NodeAddress("127.0.0.1")],
)
request = config._create_a_protobuf_conn_request(cluster_mode=True)
Expand Down
Loading

0 comments on commit 250d7ed

Please sign in to comment.