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


##########
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:
   Is there some reason why we would want to have two value formats supported 
instead of one? 🤔



-- 
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