fix:fix router label feign interceptor order. (#1069)

pull/1074/head
Haotian Zhang 1 year ago committed by GitHub
parent f08d8ff35a
commit b751a8cc72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,3 +21,4 @@
- [refactor:refactor Polaris registration.](https://github.com/Tencent/spring-cloud-tencent/pull/1055) - [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 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 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)

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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.DecodeTransferMetadataReactiveFilter;
import com.tencent.cloud.metadata.core.DecodeTransferMetadataServletFilter; import com.tencent.cloud.metadata.core.DecodeTransferMetadataServletFilter;
import com.tencent.cloud.metadata.core.EncodeTransferMedataFeignInterceptor; import com.tencent.cloud.metadata.core.EncodeTransferMedataFeignInterceptor;
@ -69,7 +69,7 @@ public class MetadataTransferAutoConfiguration {
FilterRegistrationBean<DecodeTransferMetadataServletFilter> filterRegistrationBean = FilterRegistrationBean<DecodeTransferMetadataServletFilter> filterRegistrationBean =
new FilterRegistrationBean<>(decodeTransferMetadataServletFilter); new FilterRegistrationBean<>(decodeTransferMetadataServletFilter);
filterRegistrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST); 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; return filterRegistrationBean;
} }

@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.tencent.cloud.common.constant.MetadataConstant; 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.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils; import com.tencent.cloud.common.util.JacksonUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -54,7 +55,7 @@ public class DecodeTransferMetadataReactiveFilter implements WebFilter, Ordered
@Override @Override
public int getOrder() { public int getOrder() {
return MetadataConstant.OrderConstant.WEB_FILTER_ORDER; return OrderConstant.Server.Reactive.DECODE_TRANSFER_METADATA_FILTER_ORDER;
} }
@Override @Override

@ -29,7 +29,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 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.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils; import com.tencent.cloud.common.util.JacksonUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -50,7 +50,7 @@ import static com.tencent.cloud.common.constant.MetadataConstant.HeaderName.CUST
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@Order(MetadataConstant.OrderConstant.WEB_FILTER_ORDER) @Order(OrderConstant.Server.Servlet.DECODE_TRANSFER_METADATA_FILTER_ORDER)
public class DecodeTransferMetadataServletFilter extends OncePerRequestFilter { public class DecodeTransferMetadataServletFilter extends OncePerRequestFilter {
private static final Logger LOG = LoggerFactory.getLogger(DecodeTransferMetadataServletFilter.class); private static final Logger LOG = LoggerFactory.getLogger(DecodeTransferMetadataServletFilter.class);

@ -21,7 +21,7 @@ package com.tencent.cloud.metadata.core;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Map; 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.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils; import com.tencent.cloud.common.util.JacksonUtils;
@ -51,7 +51,7 @@ public class EncodeTransferMedataFeignInterceptor implements RequestInterceptor,
@Override @Override
public int getOrder() { public int getOrder() {
return MetadataConstant.OrderConstant.METADATA_2_HEADER_INTERCEPTOR_ORDER; return OrderConstant.Client.Feign.ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER;
} }
@Override @Override

@ -23,7 +23,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Map; 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.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils; import com.tencent.cloud.common.util.JacksonUtils;
@ -50,7 +50,7 @@ public class EncodeTransferMedataRestTemplateInterceptor implements ClientHttpRe
@Override @Override
public int getOrder() { public int getOrder() {
return MetadataConstant.OrderConstant.METADATA_2_HEADER_INTERCEPTOR_ORDER; return OrderConstant.Client.RestTemplate.ENCODE_TRANSFER_METADATA_INTERCEPTOR_ORDER;
} }
@Override @Override

@ -23,6 +23,7 @@ import java.net.URLEncoder;
import java.util.Map; import java.util.Map;
import com.tencent.cloud.common.constant.MetadataConstant; 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.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
import com.tencent.cloud.common.util.JacksonUtils; 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.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_DISPOSABLE_METADATA;
import static com.tencent.cloud.common.constant.MetadataConstant.HeaderName.CUSTOM_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. * 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 { public class EncodeTransferMedataScgFilter implements GlobalFilter, Ordered {
private static final int METADATA_SCG_FILTER_ORDER = LOAD_BALANCER_CLIENT_FILTER_ORDER + 1;
@Override @Override
public int getOrder() { public int getOrder() {
return METADATA_SCG_FILTER_ORDER; return OrderConstant.Client.Scg.ENCODE_TRANSFER_METADATA_FILTER_ORDER;
} }
@Override @Override

@ -18,6 +18,7 @@
package com.tencent.cloud.metadata.core; package com.tencent.cloud.metadata.core;
import com.tencent.cloud.common.constant.MetadataConstant; import com.tencent.cloud.common.constant.MetadataConstant;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.common.metadata.config.MetadataLocalProperties; import com.tencent.cloud.common.metadata.config.MetadataLocalProperties;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -59,7 +60,7 @@ public class DecodeTransferMetadataReactiveFilterTest {
@Test @Test
public void test1() { public void test1() {
assertThat(this.metadataReactiveFilter.getOrder()) assertThat(this.metadataReactiveFilter.getOrder())
.isEqualTo(MetadataConstant.OrderConstant.WEB_FILTER_ORDER); .isEqualTo(OrderConstant.Server.Reactive.DECODE_TRANSFER_METADATA_FILTER_ORDER);
} }
@Test @Test

@ -17,7 +17,7 @@
package com.tencent.cloud.polaris.circuitbreaker.common; 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.polaris.context.PolarisConfigModifier;
import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties; import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties;
import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig;
@ -57,6 +57,6 @@ public class CircuitBreakerConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.CIRCUIT_BREAKER_ORDER; return OrderConstant.Modifier.CIRCUIT_BREAKER_ORDER;
} }
} }

@ -21,7 +21,7 @@ package com.tencent.cloud.polaris.config;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.common.util.AddressUtils;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties; import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.cloud.polaris.context.PolarisConfigModifier;
@ -106,7 +106,7 @@ public class ConfigurationModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.CONFIG_ORDER; return OrderConstant.Modifier.CONFIG_ORDER;
} }
/** /**

@ -18,7 +18,7 @@
package com.tencent.cloud.polaris; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -55,6 +55,6 @@ public class DiscoveryConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.DISCOVERY_ORDER; return OrderConstant.Modifier.DISCOVERY_ORDER;
} }
} }

@ -18,7 +18,7 @@
package com.tencent.cloud.polaris; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
import com.tencent.polaris.factory.config.consumer.DiscoveryConfigImpl; import com.tencent.polaris.factory.config.consumer.DiscoveryConfigImpl;
@ -54,6 +54,6 @@ public class PolarisDiscoveryConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.LAST; return OrderConstant.Modifier.DISCOVERY_CONFIG_ORDER;
} }
} }

@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Map; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.api.config.plugin.DefaultPlugins; import com.tencent.polaris.api.config.plugin.DefaultPlugins;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -112,6 +112,6 @@ public class ConsulConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.LAST; return OrderConstant.Modifier.CONSUL_DISCOVERY_CONFIG_ORDER;
} }
} }

@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Objects; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.api.config.plugin.DefaultPlugins; import com.tencent.polaris.api.config.plugin.DefaultPlugins;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -129,6 +129,6 @@ public class NacosConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.LAST; return OrderConstant.Modifier.NACOS_DISCOVERY_CONFIG_ORDER;
} }
} }

@ -18,6 +18,7 @@
package com.tencent.cloud.polaris.ratelimit.config; 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.PolarisSDKContextManager;
import com.tencent.cloud.polaris.context.ServiceRuleManager; import com.tencent.cloud.polaris.context.ServiceRuleManager;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration; 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.context.annotation.Configuration;
import org.springframework.lang.Nullable; 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 com.tencent.cloud.polaris.ratelimit.filter.QuotaCheckServletFilter.QUOTA_FILTER_BEAN_NAME;
import static javax.servlet.DispatcherType.ASYNC; import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.ERROR; import static javax.servlet.DispatcherType.ERROR;
@ -86,7 +86,7 @@ public class PolarisRateLimitAutoConfiguration {
quotaCheckServletFilter); quotaCheckServletFilter);
registrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST); registrationBean.setDispatcherTypes(ASYNC, ERROR, FORWARD, INCLUDE, REQUEST);
registrationBean.setName(QUOTA_FILTER_BEAN_NAME); registrationBean.setName(QUOTA_FILTER_BEAN_NAME);
registrationBean.setOrder(FILTER_ORDER); registrationBean.setOrder(OrderConstant.Server.Servlet.RATE_LIMIT_FILTER_ORDER);
return registrationBean; return registrationBean;
} }

@ -17,7 +17,7 @@
package com.tencent.cloud.polaris.ratelimit.config; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -43,6 +43,6 @@ public class RateLimitConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.CIRCUIT_BREAKER_ORDER; return OrderConstant.Modifier.RATE_LIMIT_ORDER;
} }
} }

@ -18,19 +18,12 @@
package com.tencent.cloud.polaris.ratelimit.constant; package com.tencent.cloud.polaris.ratelimit.constant;
import org.springframework.core.Ordered;
/** /**
* Constant for rate-limiter. * Constant for rate-limiter.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
public final class RateLimitConstant { public final class RateLimitConstant {
/**
* Order of filter.
*/
public static final int FILTER_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;
/** /**
* Info of rate limit. * Info of rate limit.
*/ */

@ -26,9 +26,9 @@ import java.util.Set;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import com.tencent.cloud.common.constant.HeaderConstant; 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.common.metadata.MetadataContext;
import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; 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.resolver.RateLimitRuleArgumentReactiveResolver;
import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback;
import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils; import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils;
@ -88,7 +88,7 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered {
@Override @Override
public int getOrder() { public int getOrder() {
return RateLimitConstant.FILTER_ORDER; return OrderConstant.Server.Reactive.RATE_LIMIT_FILTER_ORDER;
} }
@Override @Override
@ -110,7 +110,8 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered {
response.setRawStatusCode(polarisRateLimiterLimitedFallback.rejectHttpCode()); response.setRawStatusCode(polarisRateLimiterLimitedFallback.rejectHttpCode());
response.getHeaders().setContentType(polarisRateLimiterLimitedFallback.mediaType()); response.getHeaders().setContentType(polarisRateLimiterLimitedFallback.mediaType());
dataBuffer = response.bufferFactory().allocateBuffer() dataBuffer = response.bufferFactory().allocateBuffer()
.write(polarisRateLimiterLimitedFallback.rejectTips().getBytes(polarisRateLimiterLimitedFallback.charset())); .write(polarisRateLimiterLimitedFallback.rejectTips()
.getBytes(polarisRateLimiterLimitedFallback.charset()));
} }
else { else {
response.setRawStatusCode(polarisRateLimitProperties.getRejectHttpCode()); response.setRawStatusCode(polarisRateLimitProperties.getRejectHttpCode());
@ -118,9 +119,12 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered {
dataBuffer = response.bufferFactory().allocateBuffer() dataBuffer = response.bufferFactory().allocateBuffer()
.write(rejectTips.getBytes(StandardCharsets.UTF_8)); .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())) { 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)); return response.writeWith(Mono.just(dataBuffer));
} }

@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.tencent.cloud.common.constant.HeaderConstant; 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.common.metadata.MetadataContext;
import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; 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.resolver.RateLimitRuleArgumentServletResolver;
import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback;
import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils; import com.tencent.cloud.polaris.ratelimit.utils.QuotaCheckUtils;
@ -55,7 +55,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
* *
* @author Haotian Zhang, lepdou, cheese8 * @author Haotian Zhang, lepdou, cheese8
*/ */
@Order(RateLimitConstant.FILTER_ORDER) @Order(OrderConstant.Server.Servlet.RATE_LIMIT_FILTER_ORDER)
public class QuotaCheckServletFilter extends OncePerRequestFilter { public class QuotaCheckServletFilter extends OncePerRequestFilter {
/** /**
@ -115,7 +115,8 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter {
} }
response.addHeader(HeaderConstant.INTERNAL_CALLEE_RET_STATUS, RetStatus.RetFlowControl.getDesc()); response.addHeader(HeaderConstant.INTERNAL_CALLEE_RET_STATUS, RetStatus.RetFlowControl.getDesc());
if (Objects.nonNull(quotaResponse.getActiveRule())) { 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; return;
} }

@ -28,10 +28,10 @@ import java.util.stream.Collectors;
import com.google.protobuf.InvalidProtocolBufferException; import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat; import com.google.protobuf.util.JsonFormat;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.polaris.context.ServiceRuleManager; import com.tencent.cloud.polaris.context.ServiceRuleManager;
import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties; 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.resolver.RateLimitRuleArgumentReactiveResolver;
import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLabelReactiveResolver; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLabelReactiveResolver;
import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback; import com.tencent.cloud.polaris.ratelimit.spi.PolarisRateLimiterLimitedFallback;
@ -114,8 +114,10 @@ public class QuotaCheckReactiveFilterTest {
ServiceRuleManager serviceRuleManager = mock(ServiceRuleManager.class); ServiceRuleManager serviceRuleManager = mock(ServiceRuleManager.class);
RateLimitProto.Rule.Builder ratelimitRuleBuilder = RateLimitProto.Rule.newBuilder(); RateLimitProto.Rule.Builder ratelimitRuleBuilder = RateLimitProto.Rule.newBuilder();
InputStream inputStream = QuotaCheckServletFilterTest.class.getClassLoader().getResourceAsStream("ratelimit.json"); InputStream inputStream = QuotaCheckServletFilterTest.class.getClassLoader()
String json = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("")); .getResourceAsStream("ratelimit.json");
String json = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).lines()
.collect(Collectors.joining(""));
JsonFormat.parser().ignoringUnknownFields().merge(json, ratelimitRuleBuilder); JsonFormat.parser().ignoringUnknownFields().merge(json, ratelimitRuleBuilder);
RateLimitProto.Rule rateLimitRule = ratelimitRuleBuilder.build(); RateLimitProto.Rule rateLimitRule = ratelimitRuleBuilder.build();
RateLimitProto.RateLimit rateLimit = RateLimitProto.RateLimit.newBuilder().addRules(rateLimitRule).build(); RateLimitProto.RateLimit rateLimit = RateLimitProto.RateLimit.newBuilder().addRules(rateLimitRule).build();
@ -129,7 +131,7 @@ public class QuotaCheckReactiveFilterTest {
@Test @Test
public void testGetOrder() { public void testGetOrder() {
assertThat(this.quotaCheckReactiveFilter.getOrder()).isEqualTo(RateLimitConstant.FILTER_ORDER); assertThat(this.quotaCheckReactiveFilter.getOrder()).isEqualTo(OrderConstant.Server.Reactive.RATE_LIMIT_FILTER_ORDER);
} }
@Test @Test

@ -18,7 +18,7 @@
package com.tencent.cloud.polaris.router; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.api.config.consumer.ServiceRouterConfig; import com.tencent.polaris.api.config.consumer.ServiceRouterConfig;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -45,6 +45,6 @@ public class RouterConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.CONFIG_ORDER; return OrderConstant.Modifier.ROUTER_ORDER;
} }
} }

@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.constant.RouterConstant;
import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
@ -77,7 +78,7 @@ public class RouterLabelFeignInterceptor implements RequestInterceptor, Ordered
@Override @Override
public int getOrder() { public int getOrder() {
return 0; return OrderConstant.Client.Feign.ROUTER_LABEL_INTERCEPTOR_ORDER;
} }
@Override @Override

@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.constant.RouterConstant;
import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
@ -87,7 +88,7 @@ public class RouterLabelRestTemplateInterceptor implements ClientHttpRequestInte
@Override @Override
public int getOrder() { public int getOrder() {
return Ordered.LOWEST_PRECEDENCE; return OrderConstant.Client.RestTemplate.ROUTER_LABEL_INTERCEPTOR_ORDER;
} }
@Override @Override

@ -27,6 +27,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.tencent.cloud.common.constant.OrderConstant;
import com.tencent.cloud.common.constant.RouterConstant; import com.tencent.cloud.common.constant.RouterConstant;
import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.metadata.MetadataContextHolder; import com.tencent.cloud.common.metadata.MetadataContextHolder;
@ -71,7 +72,7 @@ public class RouterLabelFeignInterceptorTest {
Collections.singletonList(routerLabelResolver), Collections.singletonList(routerLabelResolver),
staticMetadataManager, routerRuleLabelResolver, polarisContextProperties); staticMetadataManager, routerRuleLabelResolver, polarisContextProperties);
assertThat(routerLabelFeignInterceptor.getOrder()).isEqualTo(0); assertThat(routerLabelFeignInterceptor.getOrder()).isEqualTo(OrderConstant.Client.Feign.ROUTER_LABEL_INTERCEPTOR_ORDER);
// mock request template // mock request template
RequestTemplate requestTemplate = new RequestTemplate(); RequestTemplate requestTemplate = new RequestTemplate();

@ -43,40 +43,4 @@ public final class ContextConstant {
private 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;
}
} }

@ -17,8 +17,6 @@
package com.tencent.cloud.common.constant; package com.tencent.cloud.common.constant;
import org.springframework.core.Ordered;
/** /**
* Constant for metadata. * Constant for metadata.
* *
@ -47,26 +45,6 @@ public final class MetadataConstant {
private 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. * Metadata HTTP header name.

@ -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;
}
}

@ -167,12 +167,6 @@
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-tsf-adapter-plugin</artifactId>
<version>${revision}</version>
</dependency>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-featureenv-plugin</artifactId> <artifactId>spring-cloud-tencent-featureenv-plugin</artifactId>

@ -18,8 +18,6 @@
<module>spring-cloud-tencent-featureenv-plugin</module> <module>spring-cloud-tencent-featureenv-plugin</module>
<module>spring-cloud-tencent-gateway-plugin</module> <module>spring-cloud-tencent-gateway-plugin</module>
<module>spring-cloud-starter-tencent-discovery-adapter-plugin</module> <module>spring-cloud-starter-tencent-discovery-adapter-plugin</module>
<module>spring-cloud-starter-tencent-tsf-adapter-plugin</module>
</modules> </modules>
</project> </project>

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>spring-cloud-tencent-plugin-starters</artifactId>
<groupId>com.tencent.cloud</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-cloud-starter-tencent-tsf-adapter-plugin</artifactId>
<name>Spring Cloud Starter Tencent TSF Plugin</name>
<dependencies>
<!-- Spring Cloud Tencent dependencies start -->
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-rpc-enhancement</artifactId>
</dependency>
<!-- Spring Cloud Tencent dependencies end -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@ -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();
}
}

@ -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;
}
}

@ -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);
});
}
}

@ -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) {
}
}

@ -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) {
}
}

@ -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() {
}
}

@ -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) {
}
}

@ -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) {
}
}

@ -20,7 +20,7 @@ package com.tencent.cloud.polaris.context;
import java.util.List; 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.common.util.AddressUtils;
import com.tencent.cloud.polaris.context.config.PolarisContextProperties; import com.tencent.cloud.polaris.context.config.PolarisContextProperties;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -52,6 +52,6 @@ public class ModifyAddress implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.FIRST; return OrderConstant.Modifier.ADDRESS_ORDER;
} }
} }

@ -17,7 +17,7 @@
package com.tencent.cloud.rpc.enhancement.filter; 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.EnhancedPluginContext;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType;
@ -87,7 +87,7 @@ public class EnhancedReactiveFilter implements WebFilter, Ordered {
@Override @Override
public int getOrder() { public int getOrder() {
return MetadataConstant.OrderConstant.WEB_FILTER_ORDER + 1; return OrderConstant.Server.Reactive.ENHANCED_FILTER_ORDER;
} }
} }

@ -29,7 +29,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 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.EnhancedPluginContext;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType;
@ -46,7 +46,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
* *
* @author sean yu * @author sean yu
*/ */
@Order(MetadataConstant.OrderConstant.WEB_FILTER_ORDER + 1) @Order(OrderConstant.Server.Servlet.ENHANCED_FILTER_ORDER)
public class EnhancedServletFilter extends OncePerRequestFilter { public class EnhancedServletFilter extends OncePerRequestFilter {
private final EnhancedPluginRunner pluginRunner; private final EnhancedPluginRunner pluginRunner;

@ -19,6 +19,7 @@ package com.tencent.cloud.rpc.enhancement.scg;
import java.net.URI; 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.EnhancedPluginContext;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner; import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginRunner;
import com.tencent.cloud.rpc.enhancement.plugin.EnhancedPluginType; 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.core.Ordered;
import org.springframework.web.server.ServerWebExchange; 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_LOADBALANCER_RESPONSE_ATTR;
import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR; import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_REQUEST_URL_ATTR;
@ -102,6 +102,6 @@ public class EnhancedGatewayGlobalFilter implements GlobalFilter, Ordered {
@Override @Override
public int getOrder() { public int getOrder() {
return LOAD_BALANCER_CLIENT_FILTER_ORDER + 1; return OrderConstant.Client.Scg.ENHANCED_FILTER_ORDER;
} }
} }

@ -17,7 +17,7 @@
package com.tencent.cloud.rpc.enhancement.stat.config; 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.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
import com.tencent.polaris.plugins.stat.prometheus.handler.PrometheusHandlerConfig; import com.tencent.polaris.plugins.stat.prometheus.handler.PrometheusHandlerConfig;
@ -80,6 +80,6 @@ public class StatConfigModifier implements PolarisConfigModifier {
@Override @Override
public int getOrder() { public int getOrder() {
return ContextConstant.ModifierOrder.STAT_REPORTER_ORDER; return OrderConstant.Modifier.STAT_REPORTER_ORDER;
} }
} }

Loading…
Cancel
Save