funky-eyes commented on code in PR #6754:
URL: https://github.com/apache/incubator-seata/pull/6754#discussion_r1728568459


##########
core/src/main/java/org/apache/seata/core/protocol/detector/SeataDetector.java:
##########
@@ -0,0 +1,39 @@
+package org.apache.seata.core.protocol.detector;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandler;
+import org.apache.seata.core.rpc.netty.v1.ProtocolDecoderV1;
+import org.apache.seata.core.rpc.netty.v1.ProtocolEncoderV1;
+
+public class SeataDetector implements ProtocolDetector {
+    private final byte[] MAGIC_CODE_BYTES = {(byte) 0xda, (byte) 0xda};
+    private ChannelHandler[] serverHandlers;
+
+    public SeataDetector(ChannelHandler[] serverHandlers) {
+        this.serverHandlers = serverHandlers;
+    }
+
+    @Override
+    public boolean detect(ByteBuf in) {
+        if (in.readableBytes() < MAGIC_CODE_BYTES.length) {
+            return false;
+        }
+        for (int i = 0; i < MAGIC_CODE_BYTES.length; i++) {
+            if (in.getByte(i) != MAGIC_CODE_BYTES[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public ChannelHandler[] getHandlers() {
+        ChannelHandler[] ret = new ChannelHandler[2 + serverHandlers.length];
+        ret[0] = new ProtocolDecoderV1();

Review Comment:
   应该使用MultiProtocolDecoder,或者是支持v0和v1的协议解析,定义出SeataV0Detector和SeataV1Detector
   You should use MultiProtocolDecoder, or protocol resolution that supports v0 
and v1, to define SeataV0Detector and SeataV1Detector



##########
seata-test-grpc/org/apache/seata/grpc/generated/SeataServiceGrpc.java:
##########


Review Comment:
   改为编译后生成代码到target中,而不是源码中
   After compiling, generate the code into the target instead of the source code



##########
core/src/main/java/org/apache/seata/core/protocol/Version.java:
##########
@@ -36,7 +36,7 @@ public class Version {
     /**
      * The constant CURRENT.
      */
-    private static final String CURRENT = VersionInfo.VERSION;
+    private static final String CURRENT = "2.x";

Review Comment:
   ```suggestion
       private static final String CURRENT = VersionInfo.VERSION;
   ```



-- 
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: notifications-unsubscr...@seata.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to