fix:fix router label feign interceptor order. (#1070)
parent
62eea957bb
commit
e7c3b0cadb
@ -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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
com.tencent.cloud.tsf.adapter.config.TsfDiscoveryFlow
|
@ -1 +0,0 @@
|
||||
com.tencent.cloud.tsf.adapter.config.TsfAssemblyFlow
|
@ -1 +0,0 @@
|
||||
com.tencent.cloud.tsf.adapter.config.TsfCircuitBreakerFlow
|
@ -1 +0,0 @@
|
||||
com.tencent.cloud.tsf.adapter.config.TsfLimitFlow
|
@ -1 +0,0 @@
|
||||
com.tencent.cloud.tsf.adapter.config.TsfRouterFlow
|
Loading…
Reference in new issue