Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

allow read from replicas in pipeline #402

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion rediscluster/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ def pubsub(self, **kwargs):
"""
return ClusterPubSub(self.connection_pool, **kwargs)

def pipeline(self, transaction=None, shard_hint=None):
def pipeline(self, transaction=None, shard_hint=None, read_from_replicas=False):
"""
Cluster impl:
Pipelines do not work in cluster mode the same way they do in normal mode.
Expand All @@ -461,6 +461,7 @@ def pipeline(self, transaction=None, shard_hint=None):
result_callbacks=self.result_callbacks,
response_callbacks=self.response_callbacks,
cluster_down_retry_attempts=self.cluster_down_retry_attempts,
read_from_replicas=read_from_replicas,
)

def transaction(self, *args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion rediscluster/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _send_cluster_commands(self, stack, raise_on_error=True, allow_redirections=
# refer to our internal node -> slot table that tells us where a given
# command should route to.
slot = self._determine_slot(*c.args)
node = self.connection_pool.get_node_by_slot(slot)
node = self.connection_pool.get_node_by_slot(slot, self.read_from_replicas)

# little hack to make sure the node name is populated. probably could clean this up.
self.connection_pool.nodes.set_node_name(node)
Expand Down