From b751a8cc7222ef1f4077e52fb47aa9f8d8ff0936 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Thu, 27 Jul 2023 15:32:29 +0800 Subject: [PATCH] fix:fix router label feign interceptor order. (#1069) --- CHANGELOG.md | 1 + .../MetadataTransferAutoConfiguration.java | 4 +- .../DecodeTransferMetadataReactiveFilter.java | 3 +- .../DecodeTransferMetadataServletFilter.java | 4 +- .../EncodeTransferMedataFeignInterceptor.java | 4 +- ...TransferMedataRestTemplateInterceptor.java | 4 +- .../core/EncodeTransferMedataScgFilter.java | 6 +- ...odeTransferMetadataReactiveFilterTest.java | 3 +- .../common/CircuitBreakerConfigModifier.java | 4 +- .../polaris/config/ConfigurationModifier.java | 4 +- .../polaris/DiscoveryConfigModifier.java | 4 +- .../PolarisDiscoveryConfigModifier.java | 4 +- .../extend/consul/ConsulConfigModifier.java | 4 +- .../extend/nacos/NacosConfigModifier.java | 4 +- .../PolarisRateLimitAutoConfiguration.java | 4 +- .../config/RateLimitConfigModifier.java | 4 +- .../ratelimit/constant/RateLimitConstant.java | 7 - .../filter/QuotaCheckReactiveFilter.java | 20 +- .../filter/QuotaCheckServletFilter.java | 7 +- .../filter/QuotaCheckReactiveFilterTest.java | 12 +- .../polaris/router/RouterConfigModifier.java | 4 +- .../feign/RouterLabelFeignInterceptor.java | 3 +- .../RouterLabelRestTemplateInterceptor.java | 3 +- .../RouterLabelFeignInterceptorTest.java | 3 +- .../common/constant/ContextConstant.java | 36 ---- .../common/constant/MetadataConstant.java | 22 --- .../cloud/common/constant/OrderConstant.java | 175 ++++++++++++++++++ spring-cloud-tencent-dependencies/pom.xml | 6 - spring-cloud-tencent-plugin-starters/pom.xml | 2 - .../pom.xml | 37 ---- .../PolarisTsfAdapterAutoConfiguration.java | 47 ----- .../config/PolarisTsfFlowConfigModifier.java | 46 ----- ...olarisTsfAdapterAutoConfigurationTest.java | 48 ----- .../tsf/adapter/config/TsfAssemblyFlow.java | 38 ---- .../adapter/config/TsfCircuitBreakerFlow.java | 39 ---- .../tsf/adapter/config/TsfDiscoveryFlow.java | 45 ----- .../tsf/adapter/config/TsfLimitFlow.java | 39 ---- .../tsf/adapter/config/TsfRouterFlow.java | 39 ---- ...com.tencent.polaris.api.flow.DiscoveryFlow | 1 - ...tencent.polaris.assembly.flow.AssemblyFlow | 1 - ...s.circuitbreak.api.flow.CircuitBreakerFlow | 1 - ...ncent.polaris.ratelimit.api.flow.LimitFlow | 1 - ...tencent.polaris.router.api.flow.RouterFlow | 1 - .../cloud/polaris/context/ModifyAddress.java | 4 +- .../filter/EnhancedReactiveFilter.java | 4 +- .../filter/EnhancedServletFilter.java | 4 +- .../scg/EnhancedGatewayGlobalFilter.java | 4 +- .../stat/config/StatConfigModifier.java | 4 +- 48 files changed, 247 insertions(+), 517 deletions(-) create mode 100644 spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/OrderConstant.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/pom.xml delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfiguration.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfFlowConfigModifier.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfigurationTest.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfAssemblyFlow.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfCircuitBreakerFlow.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfDiscoveryFlow.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfLimitFlow.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfRouterFlow.java delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.api.flow.DiscoveryFlow delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.assembly.flow.AssemblyFlow delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.circuitbreak.api.flow.CircuitBreakerFlow delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.ratelimit.api.flow.LimitFlow delete mode 100644 spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.router.api.flow.RouterFlow diff --git a/CHANGELOG.md b/CHANGELOG.md index 78351db97..ea2a6304a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,3 +21,4 @@ - [refactor:refactor Polaris registration.](https://github.com/Tencent/spring-cloud-tencent/pull/1055) - [fix:fix SCG report wrong service bug when using IP routing.](https://github.com/Tencent/spring-cloud-tencent/pull/1063) - [fix:fix gray release examples bug.](https://github.com/Tencent/spring-cloud-tencent/pull/1066) +- [fix:fix router label feign interceptor order.](https://github.com/Tencent/spring-cloud-tencent/pull/1069) diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/config/MetadataTransferAutoConfiguration.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/config/MetadataTransferAutoConfiguration.java index f922815f3..2b2bd4cb9 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/config/MetadataTransferAutoConfiguration.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/config/MetadataTransferAutoConfiguration.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.metadata.core.DecodeTransferMetadataReactiveFilter; import com.tencent.cloud.metadata.core.DecodeTransferMetadataServletFilter; import com.tencent.cloud.metadata.core.EncodeTransferMedataFeignInterceptor; @@ -69,7 +69,7 @@ public class MetadataTransferAutoConfiguration { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>(decodeTransferMetadataServletFilter); filterRegistrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST); - filterRegistrationBean.setOrder(MetadataConstant.OrderConstant.WEB_FILTER_ORDER); + filterRegistrationBean.setOrder(OrderConstant.Server.Servlet.DECODE_TRANSFER_METADATA_FILTER_ORDER); return filterRegistrationBean; } diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilter.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilter.java index 3c5617f8d..a1bf7a86e 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilter.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilter.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Map; import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.util.JacksonUtils; import org.slf4j.Logger; @@ -54,7 +55,7 @@ public class DecodeTransferMetadataReactiveFilter implements WebFilter, Ordered @Override public int getOrder() { - return MetadataConstant.OrderConstant.WEB_FILTER_ORDER; + return OrderConstant.Server.Reactive.DECODE_TRANSFER_METADATA_FILTER_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataServletFilter.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataServletFilter.java index c4e2eefa4..e1d26efcc 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataServletFilter.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataServletFilter.java @@ -29,7 +29,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.util.JacksonUtils; import org.slf4j.Logger; @@ -50,7 +50,7 @@ import static com.tencent.cloud.common.constant.MetadataConstant.HeaderName.CUST * * @author Haotian Zhang */ -@Order(MetadataConstant.OrderConstant.WEB_FILTER_ORDER) +@Order(OrderConstant.Server.Servlet.DECODE_TRANSFER_METADATA_FILTER_ORDER) public class DecodeTransferMetadataServletFilter extends OncePerRequestFilter { private static final Logger LOG = LoggerFactory.getLogger(DecodeTransferMetadataServletFilter.class); diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataFeignInterceptor.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataFeignInterceptor.java index 0cfc0f142..edbf5f0bc 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataFeignInterceptor.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataFeignInterceptor.java @@ -21,7 +21,7 @@ package com.tencent.cloud.metadata.core; import java.io.UnsupportedEncodingException; import java.util.Map; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.util.JacksonUtils; @@ -51,7 +51,7 @@ public class EncodeTransferMedataFeignInterceptor implements RequestInterceptor, @Override public int getOrder() { - return MetadataConstant.OrderConstant.METADATA_2_HEADER_INTERCEPTOR_ORDER; + return OrderConstant.Client.Feign.ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataRestTemplateInterceptor.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataRestTemplateInterceptor.java index 2e360cdd8..cbf4901b3 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataRestTemplateInterceptor.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataRestTemplateInterceptor.java @@ -23,7 +23,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Map; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.util.JacksonUtils; @@ -50,7 +50,7 @@ public class EncodeTransferMedataRestTemplateInterceptor implements ClientHttpRe @Override public int getOrder() { - return MetadataConstant.OrderConstant.METADATA_2_HEADER_INTERCEPTOR_ORDER; + return OrderConstant.Client.RestTemplate.ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataScgFilter.java b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataScgFilter.java index 3224db011..2eacd21a7 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataScgFilter.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/main/java/com/tencent/cloud/metadata/core/EncodeTransferMedataScgFilter.java @@ -23,6 +23,7 @@ import java.net.URLEncoder; import java.util.Map; import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.util.JacksonUtils; @@ -38,7 +39,6 @@ import org.springframework.web.server.ServerWebExchange; import static com.tencent.cloud.common.constant.ContextConstant.UTF_8; import static com.tencent.cloud.common.constant.MetadataConstant.HeaderName.CUSTOM_DISPOSABLE_METADATA; import static com.tencent.cloud.common.constant.MetadataConstant.HeaderName.CUSTOM_METADATA; -import static org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter.LOAD_BALANCER_CLIENT_FILTER_ORDER; /** * Scg filter used for writing metadata in HTTP request header. @@ -47,11 +47,9 @@ import static org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClien */ public class EncodeTransferMedataScgFilter implements GlobalFilter, Ordered { - private static final int METADATA_SCG_FILTER_ORDER = LOAD_BALANCER_CLIENT_FILTER_ORDER + 1; - @Override public int getOrder() { - return METADATA_SCG_FILTER_ORDER; + return OrderConstant.Client.Scg.ENCODE_TRANSFER_METADATA_FILTER_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilterTest.java b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilterTest.java index a1708f068..18886a917 100644 --- a/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilterTest.java +++ b/spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/DecodeTransferMetadataReactiveFilterTest.java @@ -18,6 +18,7 @@ package com.tencent.cloud.metadata.core; import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -59,7 +60,7 @@ public class DecodeTransferMetadataReactiveFilterTest { @Test public void test1() { assertThat(this.metadataReactiveFilter.getOrder()) - .isEqualTo(MetadataConstant.OrderConstant.WEB_FILTER_ORDER); + .isEqualTo(OrderConstant.Server.Reactive.DECODE_TRANSFER_METADATA_FILTER_ORDER); } @Test diff --git a/spring-cloud-starter-tencent-polaris-circuitbreaker/src/main/java/com/tencent/cloud/polaris/circuitbreaker/common/CircuitBreakerConfigModifier.java b/spring-cloud-starter-tencent-polaris-circuitbreaker/src/main/java/com/tencent/cloud/polaris/circuitbreaker/common/CircuitBreakerConfigModifier.java index 220d98490..5f53dd15d 100644 --- a/spring-cloud-starter-tencent-polaris-circuitbreaker/src/main/java/com/tencent/cloud/polaris/circuitbreaker/common/CircuitBreakerConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-circuitbreaker/src/main/java/com/tencent/cloud/polaris/circuitbreaker/common/CircuitBreakerConfigModifier.java @@ -17,7 +17,7 @@ package com.tencent.cloud.polaris.circuitbreaker.common; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; @@ -57,6 +57,6 @@ public class CircuitBreakerConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.CIRCUIT_BREAKER_ORDER; + return OrderConstant.Modifier.CIRCUIT_BREAKER_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/ConfigurationModifier.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/ConfigurationModifier.java index 7912787cc..8513ecf7f 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/ConfigurationModifier.java +++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/ConfigurationModifier.java @@ -21,7 +21,7 @@ package com.tencent.cloud.polaris.config; import java.util.ArrayList; import java.util.List; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.util.AddressUtils; import com.tencent.cloud.polaris.config.config.PolarisConfigProperties; import com.tencent.cloud.polaris.context.PolarisConfigModifier; @@ -106,7 +106,7 @@ public class ConfigurationModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.CONFIG_ORDER; + return OrderConstant.Modifier.CONFIG_ORDER; } /** diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/DiscoveryConfigModifier.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/DiscoveryConfigModifier.java index cf7a5a28b..1725519f3 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/DiscoveryConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/DiscoveryConfigModifier.java @@ -18,7 +18,7 @@ package com.tencent.cloud.polaris; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -55,6 +55,6 @@ public class DiscoveryConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.DISCOVERY_ORDER; + return OrderConstant.Modifier.DISCOVERY_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryConfigModifier.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryConfigModifier.java index bbe809d52..a8de38ea0 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryConfigModifier.java @@ -18,7 +18,7 @@ package com.tencent.cloud.polaris; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.consumer.DiscoveryConfigImpl; @@ -54,6 +54,6 @@ public class PolarisDiscoveryConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.LAST; + return OrderConstant.Modifier.DISCOVERY_CONFIG_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/consul/ConsulConfigModifier.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/consul/ConsulConfigModifier.java index e9bed3e61..af8431a5c 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/consul/ConsulConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/consul/ConsulConfigModifier.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Map; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.api.config.plugin.DefaultPlugins; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -112,6 +112,6 @@ public class ConsulConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.LAST; + return OrderConstant.Modifier.CONSUL_DISCOVERY_CONFIG_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/nacos/NacosConfigModifier.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/nacos/NacosConfigModifier.java index 03ffb9399..14e74be7c 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/nacos/NacosConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/extend/nacos/NacosConfigModifier.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.Map; import java.util.Objects; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.api.config.plugin.DefaultPlugins; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -129,6 +129,6 @@ public class NacosConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.LAST; + return OrderConstant.Modifier.NACOS_DISCOVERY_CONFIG_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/PolarisRateLimitAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/PolarisRateLimitAutoConfiguration.java index cce3b9bca..72d46d23a 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/PolarisRateLimitAutoConfiguration.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/PolarisRateLimitAutoConfiguration.java @@ -18,6 +18,7 @@ package com.tencent.cloud.polaris.ratelimit.config; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisSDKContextManager; import com.tencent.cloud.polaris.context.ServiceRuleManager; import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration; @@ -38,7 +39,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.lang.Nullable; -import static com.tencent.cloud.polaris.ratelimit.constant.RateLimitConstant.FILTER_ORDER; import static com.tencent.cloud.polaris.ratelimit.filter.QuotaCheckServletFilter.QUOTA_FILTER_BEAN_NAME; import static javax.servlet.DispatcherType.ASYNC; import static javax.servlet.DispatcherType.ERROR; @@ -86,7 +86,7 @@ public class PolarisRateLimitAutoConfiguration { quotaCheckServletFilter); registrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST); registrationBean.setName(QUOTA_FILTER_BEAN_NAME); - registrationBean.setOrder(FILTER_ORDER); + registrationBean.setOrder(OrderConstant.Server.Servlet.RATE_LIMIT_FILTER_ORDER); return registrationBean; } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/RateLimitConfigModifier.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/RateLimitConfigModifier.java index 75db264cd..6d5478184 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/RateLimitConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/config/RateLimitConfigModifier.java @@ -17,7 +17,7 @@ package com.tencent.cloud.polaris.ratelimit.config; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -43,6 +43,6 @@ public class RateLimitConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.CIRCUIT_BREAKER_ORDER; + return OrderConstant.Modifier.RATE_LIMIT_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/constant/RateLimitConstant.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/constant/RateLimitConstant.java index cdbf527a8..7535560eb 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/constant/RateLimitConstant.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/constant/RateLimitConstant.java @@ -18,19 +18,12 @@ package com.tencent.cloud.polaris.ratelimit.constant; -import org.springframework.core.Ordered; - /** * Constant for rate-limiter. * * @author Haotian Zhang */ public final class RateLimitConstant { - - /** - * Order of filter. - */ - public static final int FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; /** * Info of rate limit. */ diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java index 11dd12fee..6c5f2970e 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilter.java @@ -26,9 +26,9 @@ import java.util.Set; import javax.annotation.PostConstruct; import com.tencent.cloud.common.constant.HeaderConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; -import com.tencent.cloud.polaris.ratelimit.constant.RateLimitConstant; import com.tencent.cloud.polaris.ratelimit.resolver.RateLimitRuleArgumentReactiveResolver; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils; @@ -72,9 +72,9 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { private String rejectTips; public QuotaCheckReactiveFilter(LimitAPI limitAPI, - PolarisRateLimitProperties polarisRateLimitProperties, - RateLimitRuleArgumentReactiveResolver rateLimitRuleArgumentResolver, - @Nullable PolarisRateLimiterLimitedFallback polarisRateLimiterLimitedFallback) { + PolarisRateLimitProperties polarisRateLimitProperties, + RateLimitRuleArgumentReactiveResolver rateLimitRuleArgumentResolver, + @Nullable PolarisRateLimiterLimitedFallback polarisRateLimiterLimitedFallback) { this.limitAPI = limitAPI; this.polarisRateLimitProperties = polarisRateLimitProperties; this.rateLimitRuleArgumentResolver = rateLimitRuleArgumentResolver; @@ -88,7 +88,7 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { @Override public int getOrder() { - return RateLimitConstant.FILTER_ORDER; + return OrderConstant.Server.Reactive.RATE_LIMIT_FILTER_ORDER; } @Override @@ -110,7 +110,8 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { response.setRawStatusCode(polarisRateLimiterLimitedFallback.rejectHttpCode()); response.getHeaders().setContentType(polarisRateLimiterLimitedFallback.mediaType()); dataBuffer = response.bufferFactory().allocateBuffer() - .write(polarisRateLimiterLimitedFallback.rejectTips().getBytes(polarisRateLimiterLimitedFallback.charset())); + .write(polarisRateLimiterLimitedFallback.rejectTips() + .getBytes(polarisRateLimiterLimitedFallback.charset())); } else { response.setRawStatusCode(polarisRateLimitProperties.getRejectHttpCode()); @@ -118,9 +119,12 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered { dataBuffer = response.bufferFactory().allocateBuffer() .write(rejectTips.getBytes(StandardCharsets.UTF_8)); } - response.getHeaders().add(HeaderConstant.INTERNAL_CALLEE_RET_STATUS, RetStatus.RetFlowControl.getDesc()); + response.getHeaders() + .add(HeaderConstant.INTERNAL_CALLEE_RET_STATUS, RetStatus.RetFlowControl.getDesc()); if (Objects.nonNull(quotaResponse.getActiveRule())) { - response.getHeaders().add(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, quotaResponse.getActiveRule().getName().getValue()); + response.getHeaders() + .add(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, quotaResponse.getActiveRule().getName() + .getValue()); } return response.writeWith(Mono.just(dataBuffer)); } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java index 027ae91f2..bd8303e66 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckServletFilter.java @@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.tencent.cloud.common.constant.HeaderConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; -import com.tencent.cloud.polaris.ratelimit.constant.RateLimitConstant; import com.tencent.cloud.polaris.ratelimit.resolver.RateLimitRuleArgumentServletResolver; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils; @@ -55,7 +55,7 @@ import org.springframework.web.filter.OncePerRequestFilter; * * @author Haotian Zhang, lepdou, cheese8 */ -@Order(RateLimitConstant.FILTER_ORDER) +@Order(OrderConstant.Server.Servlet.RATE_LIMIT_FILTER_ORDER) public class QuotaCheckServletFilter extends OncePerRequestFilter { /** @@ -115,7 +115,8 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter { } response.addHeader(HeaderConstant.INTERNAL_CALLEE_RET_STATUS, RetStatus.RetFlowControl.getDesc()); if (Objects.nonNull(quotaResponse.getActiveRule())) { - response.addHeader(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, quotaResponse.getActiveRule().getName().getValue()); + response.addHeader(HeaderConstant.INTERNAL_ACTIVE_RULE_NAME, quotaResponse.getActiveRule().getName() + .getValue()); } return; } diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/test/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilterTest.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/test/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilterTest.java index bca453505..8df74af38 100644 --- a/spring-cloud-starter-tencent-polaris-ratelimit/src/test/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilterTest.java +++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/test/java/com/tencent/cloud/polaris/ratelimit/filter/QuotaCheckReactiveFilterTest.java @@ -28,10 +28,10 @@ import java.util.stream.Collectors; import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.util.JsonFormat; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.polaris.context.ServiceRuleManager; import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; -import com.tencent.cloud.polaris.ratelimit.constant.RateLimitConstant; import com.tencent.cloud.polaris.ratelimit.resolver.RateLimitRuleArgumentReactiveResolver; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLabelReactiveResolver; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; @@ -113,9 +113,11 @@ public class QuotaCheckReactiveFilterTest { ServiceRuleManager serviceRuleManager = mock(ServiceRuleManager.class); - RateLimitProto.Rule.Builder ratelimitRuleBuilder = RateLimitProto.Rule.newBuilder(); - InputStream inputStream = QuotaCheckServletFilterTest.class.getClassLoader().getResourceAsStream("ratelimit.json"); - String json = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("")); + RateLimitProto.Rule.Builder ratelimitRuleBuilder = RateLimitProto.Rule.newBuilder(); + InputStream inputStream = QuotaCheckServletFilterTest.class.getClassLoader() + .getResourceAsStream("ratelimit.json"); + String json = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines() + .collect(Collectors.joining("")); JsonFormat.parser().ignoringUnknownFields().merge(json, ratelimitRuleBuilder); RateLimitProto.Rule rateLimitRule = ratelimitRuleBuilder.build(); RateLimitProto.RateLimit rateLimit = RateLimitProto.RateLimit.newBuilder().addRules(rateLimitRule).build(); @@ -129,7 +131,7 @@ public class QuotaCheckReactiveFilterTest { @Test public void testGetOrder() { - assertThat(this.quotaCheckReactiveFilter.getOrder()).isEqualTo(RateLimitConstant.FILTER_ORDER); + assertThat(this.quotaCheckReactiveFilter.getOrder()).isEqualTo(OrderConstant.Server.Reactive.RATE_LIMIT_FILTER_ORDER); } @Test diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/RouterConfigModifier.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/RouterConfigModifier.java index 37b3dac6c..9f6d1e7d9 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/RouterConfigModifier.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/RouterConfigModifier.java @@ -18,7 +18,7 @@ package com.tencent.cloud.polaris.router; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -45,6 +45,6 @@ public class RouterConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.CONFIG_ORDER; + return OrderConstant.Modifier.ROUTER_ORDER; } } diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptor.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptor.java index 358169580..ab27144fe 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptor.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptor.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; @@ -77,7 +78,7 @@ public class RouterLabelFeignInterceptor implements RequestInterceptor, Ordered @Override public int getOrder() { - return 0; + return OrderConstant.Client.Feign.ROUTER_LABEL_INTERCEPTOR_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/resttemplate/RouterLabelRestTemplateInterceptor.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/resttemplate/RouterLabelRestTemplateInterceptor.java index a072898ac..808b2f687 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/resttemplate/RouterLabelRestTemplateInterceptor.java +++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/resttemplate/RouterLabelRestTemplateInterceptor.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; @@ -87,7 +88,7 @@ public class RouterLabelRestTemplateInterceptor implements ClientHttpRequestInte @Override public int getOrder() { - return Ordered.LOWEST_PRECEDENCE; + return OrderConstant.Client.RestTemplate.ROUTER_LABEL_INTERCEPTOR_ORDER; } @Override diff --git a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptorTest.java b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptorTest.java index adba7fa6e..9b332bb49 100644 --- a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptorTest.java +++ b/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/feign/RouterLabelFeignInterceptorTest.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContextHolder; @@ -71,7 +72,7 @@ public class RouterLabelFeignInterceptorTest { Collections.singletonList(routerLabelResolver), staticMetadataManager, routerRuleLabelResolver, polarisContextProperties); - assertThat(routerLabelFeignInterceptor.getOrder()).isEqualTo(0); + assertThat(routerLabelFeignInterceptor.getOrder()).isEqualTo(OrderConstant.Client.Feign.ROUTER_LABEL_INTERCEPTOR_ORDER); // mock request template RequestTemplate requestTemplate = new RequestTemplate(); diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java index 096f55035..108cc3bac 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java @@ -43,40 +43,4 @@ public final class ContextConstant { private ContextConstant() { } - - /** - * Order of configuration modifier. - */ - public static final class ModifierOrder { - - /** - * First modifier order. - */ - public static Integer FIRST = Integer.MIN_VALUE; - - /** - * Last modifier order. - */ - public static Integer LAST = Integer.MAX_VALUE; - - /** - * Order of circuit breaker configuration modifier. - */ - public static Integer CIRCUIT_BREAKER_ORDER = 2; - - /** - * Order of discovery configuration modifier. - */ - public static Integer DISCOVERY_ORDER = 0; - - /** - * Order of configuration modifier. - */ - public static Integer CONFIG_ORDER = 1; - - /** - * Order of stat reporter configuration modifier. - */ - public static Integer STAT_REPORTER_ORDER = 1; - } } diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/MetadataConstant.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/MetadataConstant.java index c3774baf1..3f8bb2555 100644 --- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/MetadataConstant.java +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/MetadataConstant.java @@ -17,8 +17,6 @@ package com.tencent.cloud.common.constant; -import org.springframework.core.Ordered; - /** * Constant for metadata. * @@ -47,26 +45,6 @@ public final class MetadataConstant { private MetadataConstant() { } - /** - * Order of filter, interceptor, ... - */ - public static class OrderConstant { - - /** - * Order of filter. - */ - public static final int WEB_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 9; - - /** - * Order of MetadataFirstFeignInterceptor. - */ - public static int METADATA_FIRST_FEIGN_INTERCEPTOR_ORDER = Ordered.HIGHEST_PRECEDENCE + 1; - - /** - * Order of Metadata2HeaderInterceptor. - */ - public static int METADATA_2_HEADER_INTERCEPTOR_ORDER = Ordered.LOWEST_PRECEDENCE; - } /** * Metadata HTTP header name. diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/OrderConstant.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/OrderConstant.java new file mode 100644 index 000000000..bb1acfa60 --- /dev/null +++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/OrderConstant.java @@ -0,0 +1,175 @@ +/* + * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * 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 com.tencent.cloud.common.constant; + +import org.springframework.core.Ordered; + +import static org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter.LOAD_BALANCER_CLIENT_FILTER_ORDER; + +/** + * Constant for order. + * + * @author Haotian Zhang + */ +public class OrderConstant { + + public static class Client { + /** + * Order constant for Feign. + */ + public static class Feign { + /** + * Order of encode transfer metadata interceptor. + */ + public static final int ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER = Ordered.LOWEST_PRECEDENCE - 1; + + /** + * Order of encode router label interceptor. + */ + public static final int ROUTER_LABEL_INTERCEPTOR_ORDER = Ordered.LOWEST_PRECEDENCE; + } + + /** + * Order constant for RestTemplate. + */ + public static class RestTemplate { + /** + * Order of encode transfer metadata interceptor. + */ + public static final int ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER = Ordered.LOWEST_PRECEDENCE - 1; + + /** + * Order of encode router label interceptor. + */ + public static final int ROUTER_LABEL_INTERCEPTOR_ORDER = Ordered.LOWEST_PRECEDENCE; + } + + /** + * Order constant for Spring Cloud Gateway. + */ + public static class Scg { + /** + * Order of encode transfer metadata filter. + */ + public static final int ENCODE_TRANSFER_METADATA_FILTER_ORDER = LOAD_BALANCER_CLIENT_FILTER_ORDER + 1; + + /** + * Order of enhanced filter. + */ + public static final int ENHANCED_FILTER_ORDER = LOAD_BALANCER_CLIENT_FILTER_ORDER + 1; + } + } + + public static class Server { + /** + * Order constant for Servlet. + */ + public static class Servlet { + /** + * Order of decode transfer metadata filter. + */ + public static final int DECODE_TRANSFER_METADATA_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 9; + + /** + * Order of enhanced filter. + */ + public static final int ENHANCED_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; + + /** + * Order of rate-limit filter. + */ + public static final int RATE_LIMIT_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; + } + + /** + * Order constant for Reactive. + */ + public static class Reactive { + /** + * Order of decode transfer metadata filter. + */ + public static final int DECODE_TRANSFER_METADATA_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 9; + + /** + * Order of enhanced filter. + */ + public static final int ENHANCED_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; + + /** + * Order of rate-limit filter. + */ + public static final int RATE_LIMIT_FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10; + } + } + + /** + * Order of configuration modifier. + */ + public static final class Modifier { + + /** + * Address modifier order. + */ + public static Integer ADDRESS_ORDER = Integer.MIN_VALUE; + + /** + * Discovery config modifier order. + */ + public static Integer DISCOVERY_CONFIG_ORDER = Integer.MAX_VALUE; + + /** + * Nacos discovery config modifier order. + */ + public static Integer NACOS_DISCOVERY_CONFIG_ORDER = Integer.MAX_VALUE; + + /** + * Consul discovery config modifier order. + */ + public static Integer CONSUL_DISCOVERY_CONFIG_ORDER = Integer.MAX_VALUE; + + /** + * Order of discovery configuration modifier. + */ + public static Integer DISCOVERY_ORDER = 0; + + /** + * Order of circuit breaker configuration modifier. + */ + public static Integer CIRCUIT_BREAKER_ORDER = 2; + + /** + * Order of rate-limit configuration modifier. + */ + public static Integer RATE_LIMIT_ORDER = 2; + + /** + * Order of config configuration modifier. + */ + public static Integer CONFIG_ORDER = 1; + + /** + * Order of router configuration modifier. + */ + public static Integer ROUTER_ORDER = 1; + + /** + * Order of stat reporter configuration modifier. + */ + public static Integer STAT_REPORTER_ORDER = 1; + } +} diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index a450dcdbd..e5ecf8d11 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -167,12 +167,6 @@ ${revision} - - com.tencent.cloud - spring-cloud-starter-tencent-tsf-adapter-plugin - ${revision} - - com.tencent.cloud spring-cloud-tencent-featureenv-plugin diff --git a/spring-cloud-tencent-plugin-starters/pom.xml b/spring-cloud-tencent-plugin-starters/pom.xml index 3de6b8ac8..bc2f153b9 100644 --- a/spring-cloud-tencent-plugin-starters/pom.xml +++ b/spring-cloud-tencent-plugin-starters/pom.xml @@ -18,8 +18,6 @@ spring-cloud-tencent-featureenv-plugin spring-cloud-tencent-gateway-plugin spring-cloud-starter-tencent-discovery-adapter-plugin - spring-cloud-starter-tencent-tsf-adapter-plugin - diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/pom.xml b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/pom.xml deleted file mode 100644 index 0c0deb4f1..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - spring-cloud-tencent-plugin-starters - com.tencent.cloud - ${revision} - ../pom.xml - - 4.0.0 - - spring-cloud-starter-tencent-tsf-adapter-plugin - Spring Cloud Starter Tencent TSF Plugin - - - - - - com.tencent.cloud - spring-cloud-tencent-rpc-enhancement - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.mockito - mockito-inline - test - - - diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfiguration.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfiguration.java deleted file mode 100644 index d9d2b4041..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled; -import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementAutoConfiguration; -import com.tencent.polaris.api.exception.PolarisException; - -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * PolarisTsfAdapterAutoConfiguration. - * - * @author sean yu - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnPolarisEnabled -@AutoConfigureAfter(RpcEnhancementAutoConfiguration.class) -public class PolarisTsfAdapterAutoConfiguration { - - @Bean - @ConditionalOnMissingBean - public PolarisTsfFlowConfigModifier polarisFlowConfigModifier() throws PolarisException { - return new PolarisTsfFlowConfigModifier(); - } - - - -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfFlowConfigModifier.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfFlowConfigModifier.java deleted file mode 100644 index 335e55ae3..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/main/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfFlowConfigModifier.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.cloud.common.constant.ContextConstant; -import com.tencent.cloud.polaris.context.PolarisConfigModifier; -import com.tencent.polaris.factory.config.ConfigurationImpl; - -/** - * PolarisTsfFlowConfigModifier. - * - * @author sean yu - */ -public class PolarisTsfFlowConfigModifier implements PolarisConfigModifier { - - /** - * Polaris Tsf Flow Name. - */ - public static final String TSF_FLOW_NAME = "tsf"; - - @Override - public void modify(ConfigurationImpl configuration) { - configuration.getGlobal().getSystem().getFlow().setName(TSF_FLOW_NAME); - } - - @Override - public int getOrder() { - return ContextConstant.ModifierOrder.FIRST; - } - -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfigurationTest.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfigurationTest.java deleted file mode 100644 index fa8e4120c..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/PolarisTsfAdapterAutoConfigurationTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * PolarisTsfAdapterAutoConfigurationTest. - * - * @author sean yu - */ -public class PolarisTsfAdapterAutoConfigurationTest { - - private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of( - PolarisContextAutoConfiguration.class, - PolarisTsfAdapterAutoConfiguration.class - )); - - @Test - public void testDefaultInitialization() { - this.contextRunner.run(context -> { - assertThat(context).hasSingleBean(PolarisTsfFlowConfigModifier.class); - }); - } - -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfAssemblyFlow.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfAssemblyFlow.java deleted file mode 100644 index bef51db17..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfAssemblyFlow.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.polaris.assembly.flow.AssemblyFlow; -import com.tencent.polaris.client.api.SDKContext; - -/** - * TsfAssemblyFlow. - * - * @author sean yu - */ -public class TsfAssemblyFlow implements AssemblyFlow { - @Override - public String getName() { - return PolarisTsfFlowConfigModifier.TSF_FLOW_NAME; - } - - @Override - public void setSDKContext(SDKContext sdkContext) { - - } -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfCircuitBreakerFlow.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfCircuitBreakerFlow.java deleted file mode 100644 index e01d3af4e..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfCircuitBreakerFlow.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.polaris.circuitbreak.api.flow.CircuitBreakerFlow; -import com.tencent.polaris.client.api.SDKContext; - -/** - * TsfRouterFlow. - * - * @author sean yu - */ -public class TsfCircuitBreakerFlow implements CircuitBreakerFlow { - - @Override - public String getName() { - return PolarisTsfFlowConfigModifier.TSF_FLOW_NAME; - } - - @Override - public void setSDKContext(SDKContext sdkContext) { - - } -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfDiscoveryFlow.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfDiscoveryFlow.java deleted file mode 100644 index b0283242f..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfDiscoveryFlow.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.polaris.api.flow.DiscoveryFlow; -import com.tencent.polaris.client.api.SDKContext; - -/** - * TsfDiscoveryFlow. - * - * @author sean yu - */ -public class TsfDiscoveryFlow implements DiscoveryFlow { - - - @Override - public String getName() { - return PolarisTsfFlowConfigModifier.TSF_FLOW_NAME; - } - - @Override - public void setSDKContext(SDKContext sdkContext) { - - } - - @Override - public void destroy() { - - } -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfLimitFlow.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfLimitFlow.java deleted file mode 100644 index 3ac9b4b1e..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfLimitFlow.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.polaris.client.api.SDKContext; -import com.tencent.polaris.ratelimit.api.flow.LimitFlow; - -/** - * TsfRouterFlow. - * - * @author sean yu - */ -public class TsfLimitFlow implements LimitFlow { - - @Override - public String getName() { - return PolarisTsfFlowConfigModifier.TSF_FLOW_NAME; - } - - @Override - public void setSDKContext(SDKContext sdkContext) { - - } -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfRouterFlow.java b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfRouterFlow.java deleted file mode 100644 index 644d59bb0..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/java/com/tencent/cloud/tsf/adapter/config/TsfRouterFlow.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Spring Cloud Tencent available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * 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 com.tencent.cloud.tsf.adapter.config; - -import com.tencent.polaris.client.api.SDKContext; -import com.tencent.polaris.router.api.flow.RouterFlow; - -/** - * TsfRouterFlow. - * - * @author sean yu - */ -public class TsfRouterFlow implements RouterFlow { - - @Override - public String getName() { - return PolarisTsfFlowConfigModifier.TSF_FLOW_NAME; - } - - @Override - public void setSDKContext(SDKContext sdkContext) { - - } -} diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.api.flow.DiscoveryFlow b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.api.flow.DiscoveryFlow deleted file mode 100644 index 639ce8bd7..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.api.flow.DiscoveryFlow +++ /dev/null @@ -1 +0,0 @@ -com.tencent.cloud.tsf.adapter.config.TsfDiscoveryFlow \ No newline at end of file diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.assembly.flow.AssemblyFlow b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.assembly.flow.AssemblyFlow deleted file mode 100644 index bd5df065c..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.assembly.flow.AssemblyFlow +++ /dev/null @@ -1 +0,0 @@ -com.tencent.cloud.tsf.adapter.config.TsfAssemblyFlow \ No newline at end of file diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.circuitbreak.api.flow.CircuitBreakerFlow b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.circuitbreak.api.flow.CircuitBreakerFlow deleted file mode 100644 index 92c38e742..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.circuitbreak.api.flow.CircuitBreakerFlow +++ /dev/null @@ -1 +0,0 @@ -com.tencent.cloud.tsf.adapter.config.TsfCircuitBreakerFlow \ No newline at end of file diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.ratelimit.api.flow.LimitFlow b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.ratelimit.api.flow.LimitFlow deleted file mode 100644 index 54507bb07..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.ratelimit.api.flow.LimitFlow +++ /dev/null @@ -1 +0,0 @@ -com.tencent.cloud.tsf.adapter.config.TsfLimitFlow \ No newline at end of file diff --git a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.router.api.flow.RouterFlow b/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.router.api.flow.RouterFlow deleted file mode 100644 index 2ed23f638..000000000 --- a/spring-cloud-tencent-plugin-starters/spring-cloud-starter-tencent-tsf-adapter-plugin/src/test/resources/META-INF/services/com.tencent.polaris.router.api.flow.RouterFlow +++ /dev/null @@ -1 +0,0 @@ -com.tencent.cloud.tsf.adapter.config.TsfRouterFlow \ No newline at end of file diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java index 1e79f751e..68e9f2c4c 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/ModifyAddress.java @@ -20,7 +20,7 @@ package com.tencent.cloud.polaris.context; import java.util.List; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.common.util.AddressUtils; import com.tencent.cloud.polaris.context.config.PolarisContextProperties; import com.tencent.polaris.factory.config.ConfigurationImpl; @@ -52,6 +52,6 @@ public class ModifyAddress implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.FIRST; + return OrderConstant.Modifier.ADDRESS_ORDER; } } diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java index 4fa6899ce..ca2b0e912 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedReactiveFilter.java @@ -17,7 +17,7 @@ package com.tencent.cloud.rpc.enhancement.filter; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginContext; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; @@ -87,7 +87,7 @@ public class EnhancedReactiveFilter implements WebFilter, Ordered { @Override public int getOrder() { - return MetadataConstant.OrderConstant.WEB_FILTER_ORDER + 1; + return OrderConstant.Server.Reactive.ENHANCED_FILTER_ORDER; } } diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java index 9d404281c..054958d13 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/filter/EnhancedServletFilter.java @@ -29,7 +29,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.tencent.cloud.common.constant.MetadataConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginContext; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; @@ -46,7 +46,7 @@ import org.springframework.web.filter.OncePerRequestFilter; * * @author sean yu */ -@Order(MetadataConstant.OrderConstant.WEB_FILTER_ORDER + 1) +@Order(OrderConstant.Server.Servlet.ENHANCED_FILTER_ORDER) public class EnhancedServletFilter extends OncePerRequestFilter { private final EnhancedPluginRunner pluginRunner; diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java index e403d8d4d..a838b6466 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/scg/EnhancedGatewayGlobalFilter.java @@ -19,6 +19,7 @@ package com.tencent.cloud.rpc.enhancement.scg; import java.net.URI; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginContext; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; @@ -33,7 +34,6 @@ import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; import org.springframework.web.server.ServerWebExchange; -import static org.springframework.cloud.gateway.filter.ReactiveLoadBalancerClientFilter.LOAD_BALANCER_CLIENT_FILTER_ORDER; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_LOADBALANCER_RESPONSE_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; @@ -102,6 +102,6 @@ public class EnhancedGatewayGlobalFilter implements GlobalFilter, Ordered { @Override public int getOrder() { - return LOAD_BALANCER_CLIENT_FILTER_ORDER + 1; + return OrderConstant.Client.Scg.ENHANCED_FILTER_ORDER; } } diff --git a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/StatConfigModifier.java b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/StatConfigModifier.java index 0f06c9651..abaac1c93 100644 --- a/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/StatConfigModifier.java +++ b/spring-cloud-tencent-rpc-enhancement/src/main/java/com/tencent/cloud/rpc/enhancement/stat/config/StatConfigModifier.java @@ -17,7 +17,7 @@ package com.tencent.cloud.rpc.enhancement.stat.config; -import com.tencent.cloud.common.constant.ContextConstant; +import com.tencent.cloud.common.constant.OrderConstant; import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.plugins.stat.prometheus.handler.PrometheusHandlerConfig; @@ -80,6 +80,6 @@ public class StatConfigModifier implements PolarisConfigModifier { @Override public int getOrder() { - return ContextConstant.ModifierOrder.STAT_REPORTER_ORDER; + return OrderConstant.Modifier.STAT_REPORTER_ORDER; } }