Skip to content

Adding load balancing strategy configuration to cluster clients(replacement for 'read_from_replicas' config) #3563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changing the LoadBalancingStrategy type hints to be defined as option…
…al. Fixed wording in pydocs
  • Loading branch information
petyaslavova committed Mar 18, 2025
commit e8f5da5bfa18839d50bfc2bca991c992dd0ef600
7 changes: 4 additions & 3 deletions redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,14 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommand
https://redis.io/docs/manual/scaling/#redis-cluster-configuration-parameters
:param read_from_replicas:
| @deprecated - please use load_balancing_strategy instead
| Enable read from replicas in READONLY mode. You can read possibly stale data.
| Enable read from replicas in READONLY mode.
When set to true, read commands will be assigned between the primary and
its replications in a Round-Robin manner.
The data read from replicas is eventually consistent with the data in primary nodes.
:param load_balancing_strategy:
| Enable read from replicas in READONLY mode and defines the load balancing
strategy that will be used for cluster node selection.
You can read possibly stale data (when reading from replicas).
The data read from replicas is eventually consistent with the data in primary nodes.
:param reinitialize_steps:
| Specifies the number of MOVED errors that need to occur before reinitializing
the whole cluster topology. If a MOVED error occurs and the cluster does not
Expand Down Expand Up @@ -236,7 +237,7 @@ def __init__(
startup_nodes: Optional[List["ClusterNode"]] = None,
require_full_coverage: bool = True,
read_from_replicas: bool = False,
load_balancing_strategy: Union[LoadBalancingStrategy, None] = None,
load_balancing_strategy: Optional[LoadBalancingStrategy] = None,
reinitialize_steps: int = 5,
cluster_error_retry_attempts: int = 3,
connection_error_retry_attempts: int = 3,
Expand Down
4 changes: 2 additions & 2 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def __init__(
require_full_coverage: bool = False,
reinitialize_steps: int = 5,
read_from_replicas: bool = False,
load_balancing_strategy: Union["LoadBalancingStrategy", None] = None,
load_balancing_strategy: Optional["LoadBalancingStrategy"] = None,
dynamic_startup_nodes: bool = True,
url: Optional[str] = None,
address_remap: Optional[Callable[[Tuple[str, int]], Tuple[str, int]]] = None,
Expand Down Expand Up @@ -535,7 +535,7 @@ def __init__(
:param load_balancing_strategy:
Enable read from replicas in READONLY mode and defines the load balancing
strategy that will be used for cluster node selection.
You can read possibly stale data (when reading from replicas).
The data read from replicas is eventually consistent with the data in primary nodes.
:param dynamic_startup_nodes:
Set the RedisCluster's startup nodes to all of the discovered nodes.
If true (default value), the cluster's discovered nodes will be used to
Expand Down