Miretpl commented on code in PR #71067:
URL: https://github.com/apache/airflow/pull/71067#discussion_r3798300640


##########
providers/redis/src/airflow/providers/redis/hooks/redis.py:
##########
@@ -111,18 +130,49 @@ def get_conn(self):
                     "lib_name": 
f"redis-py(apache-airflow-providers-redis_v{provider_version})",
                 }
 
-            self.redis = Redis(
-                host=self.host,
-                port=self.port,
-                username=self.username,
-                password=self.password,
-                db=self.db,
-                **ssl_args,
-                **driver_info_options,
-            )
+            if self.cluster:
+                self.redis = RedisCluster(
+                    host=self.host,
+                    port=self.port,
+                    startup_nodes=self._build_startup_nodes(),
+                    username=self.username,
+                    password=self.password,
+                    **ssl_args,
+                    **driver_info_options,
+                )
+            else:
+                self.redis = Redis(
+                    host=self.host,
+                    port=self.port,
+                    username=self.username,
+                    password=self.password,
+                    db=self.db,
+                    **ssl_args,
+                    **driver_info_options,
+                )
 
         return self.redis
 
+    def _build_startup_nodes(self) -> list[ClusterNode]:
+        """Build redis-py cluster nodes from the ``startup_nodes`` extra, 
given as ``host`` or ``host:port``."""
+        if not self.startup_nodes:
+            return []
+
+        entries = self.startup_nodes.split(",") if 
isinstance(self.startup_nodes, str) else self.startup_nodes

Review Comment:
   Maybe instead of assuming what the user will enter, we should verify values 
and raise an exception if they are not, e.g. a list of strings?



##########
providers/redis/docs/connections.rst:
##########
@@ -64,3 +73,26 @@ Certificate path
 
 Enable hostname check
     If set, match the hostname during the SSL handshake (Default is ``False``).
+
+.. _redis-cluster-mode:
+
+Cluster mode

Review Comment:
   ```suggestion
   Redis Cluster Deployment
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to