You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/20 06:34:44 UTC
[incubator-linkis] branch dev-1.3.1 updated: linkis-spring-cloud-gateway module errorcode optimization and documentation (#3470)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new 962c103d7 linkis-spring-cloud-gateway module errorcode optimization and documentation (#3470)
962c103d7 is described below
commit 962c103d7472a43b36aec0484109d68d0225c597
Author: huangxiaoping <35...@users.noreply.github.com>
AuthorDate: Tue Sep 20 14:34:40 2022 +0800
linkis-spring-cloud-gateway module errorcode optimization and documentation (#3470)
---
docs/errorcode/linkis-spring-cloud-gateway.md | 12 +++
.../errorcode/GatewayErrorCodeSummary.java | 86 ++++++++++++++++++++++
.../errorcode/GatewayErrorConstants.scala | 22 ------
.../websocket/WebsocketGatewaySession.scala | 4 +-
.../src/test/java/GatewayErrorCodeSummaryTest.java | 86 ++++++++++++++++++++++
5 files changed, 186 insertions(+), 24 deletions(-)
diff --git a/docs/errorcode/linkis-spring-cloud-gateway.md b/docs/errorcode/linkis-spring-cloud-gateway.md
new file mode 100644
index 000000000..0d26c2e58
--- /dev/null
+++ b/docs/errorcode/linkis-spring-cloud-gateway.md
@@ -0,0 +1,12 @@
+## linkis-spring-cloud-gateway errorcode
+
+
+| 模块名(服务名) | 错误码 | 描述 | module |
+| -------- | -------- | ----- |---------|
+|linkis-spring-cloud-gateway|13001|Repeatedly creating a WebSocket connection(重复创建WebSocket连接)|Websocket|
+
+
+
+
+
+
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/java/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorCodeSummary.java b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/java/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorCodeSummary.java
new file mode 100644
index 000000000..6383ee21b
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/java/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorCodeSummary.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.gateway.springcloud.errorcode;
+
+import org.apache.linkis.common.errorcode.ErrorCodeUtils;
+
+public enum GatewayErrorCodeSummary {
+ /**
+ * 10000-10999 linkis-frame 11000-12999 linkis-commons 13000-14999 linkis-spring-cloud-services
+ * 15000-19999 linkis-public-enhancements 20000-24999 linkis-computation-governance 25000-25999
+ * linkis-extensions 26000-29999 linkis-engineconn-plugins
+ */
+ WEBSOCKET_CONNECT_ERROR(
+ 13001,
+ "Repeatedly creating a WebSocket connection(重复创建WebSocket连接)",
+ "The service instance has created a WebSocket connection before, and cannot be created repeatedly(服务实例之前已经创建过WebSocket连接, 不能重复创建)",
+ "linkis-spring-cloud-gateway");
+
+ private int errorCode;
+
+ private String errorDesc;
+
+ private String comment;
+
+ private String module;
+
+ GatewayErrorCodeSummary(int errorCode, String errorDesc, String comment, String module) {
+ ErrorCodeUtils.validateErrorCode(errorCode, 13000, 14999); // 13000-14999
+ this.errorCode = errorCode;
+ this.errorDesc = errorDesc;
+ this.comment = comment;
+ this.module = module;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorDesc() {
+ return errorDesc;
+ }
+
+ public void setErrorDesc(String errorDesc) {
+ this.errorDesc = errorDesc;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ public String getModule() {
+ return module;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ @Override
+ public String toString() {
+ return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+ }
+}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorConstants.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorConstants.scala
deleted file mode 100644
index 49b8a8f93..000000000
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/errorcode/GatewayErrorConstants.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.linkis.gateway.springcloud.errorcode
-
-object GatewayErrorConstants {
- val WEBSOCKET_CONNECT_ERROR = 10032
-}
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/websocket/WebsocketGatewaySession.scala b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/websocket/WebsocketGatewaySession.scala
index 3a97877de..3c2ca7ace 100644
--- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/websocket/WebsocketGatewaySession.scala
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/websocket/WebsocketGatewaySession.scala
@@ -20,7 +20,7 @@ package org.apache.linkis.gateway.springcloud.websocket
import org.apache.linkis.common.ServiceInstance
import org.apache.linkis.common.utils.Utils
import org.apache.linkis.gateway.exception.GatewayErrorException
-import org.apache.linkis.gateway.springcloud.errorcode.GatewayErrorConstants
+import org.apache.linkis.gateway.springcloud.errorcode.GatewayErrorCodeSummary
import org.apache.linkis.gateway.springcloud.websocket.SpringCloudGatewayWebsocketUtils._
import org.apache.linkis.server.conf.ServerConfiguration
@@ -65,7 +65,7 @@ class GatewayWebSocketSessionConnection(
) {
proxySession.close(CloseStatus.SERVER_ERROR)
throw new GatewayErrorException(
- GatewayErrorConstants.WEBSOCKET_CONNECT_ERROR,
+ GatewayErrorCodeSummary.WEBSOCKET_CONNECT_ERROR.getErrorCode,
s"Create a " +
s"WebSocket connection for" +
s" ${serviceInstance.getApplicationName} repeatedly!(重复地为${serviceInstance.getApplicationName}创建WebSocket连接!)"
diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/test/java/GatewayErrorCodeSummaryTest.java b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/test/java/GatewayErrorCodeSummaryTest.java
new file mode 100644
index 000000000..22a2d7321
--- /dev/null
+++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/test/java/GatewayErrorCodeSummaryTest.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.gateway.springcloud.errorcode.GatewayErrorCodeSummary.WEBSOCKET_CONNECT_ERROR;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class GatewayErrorCodeSummaryTest {
+
+ @Test
+ void testGetErrorCode() {
+ assertEquals(13001, WEBSOCKET_CONNECT_ERROR.getErrorCode());
+ }
+
+ @Test
+ void testSetErrorCode() {
+ WEBSOCKET_CONNECT_ERROR.setErrorCode(1);
+ assertEquals(1, WEBSOCKET_CONNECT_ERROR.getErrorCode());
+ WEBSOCKET_CONNECT_ERROR.setErrorCode(13001);
+ assertEquals(13001, WEBSOCKET_CONNECT_ERROR.getErrorCode());
+ }
+
+ @Test
+ void testGetErrorDesc() {
+ assertEquals(
+ "Repeatedly creating a WebSocket connection(重复创建WebSocket连接)",
+ WEBSOCKET_CONNECT_ERROR.getErrorDesc());
+ }
+
+ @Test
+ void testSetErrorDesc() {
+ WEBSOCKET_CONNECT_ERROR.setErrorDesc("test");
+ assertEquals("test", WEBSOCKET_CONNECT_ERROR.getErrorDesc());
+ WEBSOCKET_CONNECT_ERROR.setErrorDesc(
+ "Repeatedly creating a WebSocket connection(重复创建WebSocket连接)");
+ assertEquals(
+ "Repeatedly creating a WebSocket connection(重复创建WebSocket连接)",
+ WEBSOCKET_CONNECT_ERROR.getErrorDesc());
+ }
+
+ @Test
+ void testGetComment() {
+ assertEquals(
+ "The service instance has created a WebSocket connection before, and cannot be created repeatedly(服务实例之前已经创建过WebSocket连接, 不能重复创建)",
+ WEBSOCKET_CONNECT_ERROR.getComment());
+ }
+
+ @Test
+ void testSetComment() {
+ WEBSOCKET_CONNECT_ERROR.setComment("test");
+ assertEquals("test", WEBSOCKET_CONNECT_ERROR.getComment());
+ WEBSOCKET_CONNECT_ERROR.setComment(
+ "The service instance has created a WebSocket connection before, and cannot be created repeatedly(服务实例之前已经创建过WebSocket连接, 不能重复创建)");
+ assertEquals(
+ "The service instance has created a WebSocket connection before, and cannot be created repeatedly(服务实例之前已经创建过WebSocket连接, 不能重复创建)",
+ WEBSOCKET_CONNECT_ERROR.getComment());
+ }
+
+ @Test
+ void testGetModule() {
+ assertEquals("Websocket", WEBSOCKET_CONNECT_ERROR.getModule());
+ }
+
+ @Test
+ void testSetModule() {
+ WEBSOCKET_CONNECT_ERROR.setModule("test");
+ assertEquals("test", WEBSOCKET_CONNECT_ERROR.getModule());
+ WEBSOCKET_CONNECT_ERROR.setModule("Websocket");
+ assertEquals("Websocket", WEBSOCKET_CONNECT_ERROR.getModule());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org