You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/09/05 18:56:29 UTC

[GitHub] [incubator-seatunnel] githublaohu commented on a diff in pull request #2647: [Feature][Connector-V2] Add redis sink connector

githublaohu commented on code in PR #2647:
URL: https://github.com/apache/incubator-seatunnel/pull/2647#discussion_r963089766


##########
seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config/RedisParameters.java:
##########
@@ -50,4 +52,13 @@ public void buildWithConfig(Config config) {
             throw new RuntimeException("Redis source connector only support these data types [key, hash, list, set, zset]", e);
         }
     }
+
+    public Jedis buildJedis() {
+        Jedis jedis;
+        jedis = new Jedis(host, port);

Review Comment:
   是否可以支持哨兵与分布式模式,Jedis好像是不安全的,请使用连接池模式。或则使用lett库。sink与source只会被一个线程调用吗?



##########
seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config/RedisParameters.java:
##########
@@ -50,4 +52,13 @@ public void buildWithConfig(Config config) {
             throw new RuntimeException("Redis source connector only support these data types [key, hash, list, set, zset]", e);
         }
     }
+
+    public Jedis buildJedis() {
+        Jedis jedis;
+        jedis = new Jedis(host, port);
+        if (StringUtils.isNotBlank(auth)) {
+            jedis.auth(auth);
+        }

Review Comment:
   少一个index配置



##########
seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config/RedisDataType.java:
##########
@@ -29,32 +29,59 @@
 
 public enum RedisDataType {
     KEY {
+        @Override
+        public void set(Jedis jedis, String key, String value) {
+            jedis.set(key, value);
+        }
+
         @Override
         public List<String> get(Jedis jedis, String key) {
             return Collections.singletonList(jedis.get(key));
         }
     },
     HASH {
+        @Override
+        public void set(Jedis jedis, String key, String value) {
+            Map<String, String> fieldsMap = JsonUtils.toMap(value);
+            jedis.hset(key, fieldsMap);
+        }
+
         @Override
         public List<String> get(Jedis jedis, String key) {
             Map<String, String> kvMap = jedis.hgetAll(key);
             return Collections.singletonList(JsonUtils.toJsonString(kvMap));
         }
+
     },
     LIST {
+        @Override
+        public void set(Jedis jedis, String key, String value) {
+            jedis.lpush(key, value);

Review Comment:
   Redis Lpush 命令将一个或多个值插入到列表头部。lrange 命名从头部拉数据。 是栈模式。
   应该是头部插入,尾部取吧



##########
seatunnel-connectors-v2/connector-redis/src/main/java/org/apache/seatunnel/connectors/seatunnel/redis/config/RedisParameters.java:
##########
@@ -50,4 +52,13 @@ public void buildWithConfig(Config config) {
             throw new RuntimeException("Redis source connector only support these data types [key, hash, list, set, zset]", e);
         }
     }
+
+    public Jedis buildJedis() {
+        Jedis jedis;

Review Comment:
   与58行是否可以合在一起



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org