optimize configuration conditional & optimize config data tips (#603)

pull/610/head
lepdou 2 years ago committed by GitHub
parent 0dd3cadc10
commit 7ea533b0cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,3 +4,4 @@
- [Fix issue 593:When the project depends on spring-retry, executing restTemplate to call microservice and reporting NPE error](https://github.com/Tencent/spring-cloud-tencent/pull/594) - [Fix issue 593:When the project depends on spring-retry, executing restTemplate to call microservice and reporting NPE error](https://github.com/Tencent/spring-cloud-tencent/pull/594)
- [Optimize: remove discovery module useless code](https://github.com/Tencent/spring-cloud-tencent/pull/595) - [Optimize: remove discovery module useless code](https://github.com/Tencent/spring-cloud-tencent/pull/595)
- [Optimize: remove useless code for rest template router](https://github.com/Tencent/spring-cloud-tencent/pull/601) - [Optimize: remove useless code for rest template router](https://github.com/Tencent/spring-cloud-tencent/pull/601)
- [Optimize: optimize configuration conditional & optimize config data tips](https://github.com/Tencent/spring-cloud-tencent/pull/603)

@ -0,0 +1,38 @@
/*
* 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.polaris.circuitbreaker.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
/**
* Condition if Polaris circuit breaker is enabled.
* @author lepdou 2022-09-23
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(name = "spring.cloud.polaris.circuitbreaker.enabled", matchIfMissing = true)
public @interface ConditionalOnPolarisCircuitBreakerEnabled {
}

@ -18,7 +18,6 @@
package com.tencent.cloud.polaris.circuitbreaker.config; package com.tencent.cloud.polaris.circuitbreaker.config;
import com.tencent.cloud.common.constant.ContextConstant; import com.tencent.cloud.common.constant.ContextConstant;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.PolarisConfigModifier; import com.tencent.cloud.polaris.context.PolarisConfigModifier;
import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementAutoConfiguration; import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementAutoConfiguration;
import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties; import com.tencent.cloud.rpc.enhancement.config.RpcEnhancementReporterProperties;
@ -27,7 +26,6 @@ import com.tencent.polaris.factory.config.ConfigurationImpl;
import com.tencent.polaris.plugins.router.healthy.RecoverRouterConfig; import com.tencent.polaris.plugins.router.healthy.RecoverRouterConfig;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -37,8 +35,7 @@ import org.springframework.context.annotation.Configuration;
* @author lepdou 2022-03-29 * @author lepdou 2022-03-29
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled @ConditionalOnPolarisCircuitBreakerEnabled
@ConditionalOnProperty(value = "spring.cloud.polaris.circuitbreaker.enabled", havingValue = "true", matchIfMissing = true)
@AutoConfigureAfter(RpcEnhancementAutoConfiguration.class) @AutoConfigureAfter(RpcEnhancementAutoConfiguration.class)
public class PolarisCircuitBreakerAutoConfiguration { public class PolarisCircuitBreakerAutoConfiguration {

@ -0,0 +1,38 @@
/*
* 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.polaris.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
/**
* Condition if Polaris configuration is enabled.
* @author lepdou 2022-09-23
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(value = "spring.cloud.polaris.config.enabled", matchIfMissing = true)
public @interface ConditionalOnPolarisConfigEnabled {
}

@ -30,11 +30,9 @@ import com.tencent.cloud.polaris.config.listener.PolarisConfigChangeEventListene
import com.tencent.cloud.polaris.config.spring.annotation.SpringValueProcessor; import com.tencent.cloud.polaris.config.spring.annotation.SpringValueProcessor;
import com.tencent.cloud.polaris.config.spring.property.PlaceholderHelper; import com.tencent.cloud.polaris.config.spring.property.PlaceholderHelper;
import com.tencent.cloud.polaris.config.spring.property.SpringValueRegistry; import com.tencent.cloud.polaris.config.spring.property.SpringValueRegistry;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans;
import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder;
@ -48,8 +46,7 @@ import org.springframework.context.annotation.Configuration;
* @author lepdou 2022-03-28 * @author lepdou 2022-03-28
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled @ConditionalOnPolarisConfigEnabled
@ConditionalOnProperty(value = "spring.cloud.polaris.config.enabled", matchIfMissing = true)
public class PolarisConfigAutoConfiguration { public class PolarisConfigAutoConfiguration {
@Bean @Bean

@ -23,7 +23,6 @@ import com.tencent.cloud.polaris.config.adapter.PolarisConfigFileLocator;
import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager; import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
import com.tencent.cloud.polaris.config.condition.ConditionalOnReflectRefreshType; import com.tencent.cloud.polaris.config.condition.ConditionalOnReflectRefreshType;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties; import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration; import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
import com.tencent.cloud.polaris.context.config.PolarisContextProperties; import com.tencent.cloud.polaris.context.config.PolarisContextProperties;
import com.tencent.polaris.client.api.SDKContext; import com.tencent.polaris.client.api.SDKContext;
@ -31,7 +30,6 @@ import com.tencent.polaris.configuration.api.core.ConfigFileService;
import com.tencent.polaris.configuration.factory.ConfigFileServiceFactory; import com.tencent.polaris.configuration.factory.ConfigFileServiceFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SearchStrategy; import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans; import org.springframework.cloud.context.properties.ConfigurationPropertiesBeans;
import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder; import org.springframework.cloud.context.properties.ConfigurationPropertiesRebinder;
@ -46,8 +44,7 @@ import org.springframework.core.env.Environment;
* @author lepdou 2022-03-10 * @author lepdou 2022-03-10
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled @ConditionalOnPolarisConfigEnabled
@ConditionalOnProperty(value = "spring.cloud.polaris.config.enabled", matchIfMissing = true)
@Import(PolarisContextAutoConfiguration.class) @Import(PolarisContextAutoConfiguration.class)
public class PolarisConfigBootstrapAutoConfiguration { public class PolarisConfigBootstrapAutoConfiguration {

@ -27,9 +27,10 @@ public class PolarisImportExceptionFailureAnalyzer extends
else { else {
description = "No spring.config.import property has been defined"; description = "No spring.config.import property has been defined";
} }
String action = "Add a spring.config.import=polaris property to your configuration.\n" String action = "\t1. Add a spring.config.import=polaris property to your configuration.\n"
+ "\tIf configuration is not required add spring.config.import=optional:polaris instead.\n" + "\t2. If configuration is not required add spring.config.import=optional:polaris instead.\n"
+ "\tTo disable this check, set spring.cloud.polaris.config.import-check.enabled=false."; + "\t3. If you still want use bootstrap.yml, "
+ "you can add <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> dependency for compatible upgrade.";
return new FailureAnalysis(description, action, cause); return new FailureAnalysis(description, action, cause);
} }
} }

@ -17,6 +17,7 @@
package com.tencent.cloud.polaris.config.endpoint; package com.tencent.cloud.polaris.config.endpoint;
import com.tencent.cloud.polaris.config.ConditionalOnPolarisConfigEnabled;
import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager; import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
import com.tencent.cloud.polaris.config.config.PolarisConfigProperties; import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
@ -24,7 +25,6 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.condition.Conditi
import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -35,7 +35,7 @@ import org.springframework.context.annotation.Configuration;
**/ **/
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Endpoint.class) @ConditionalOnClass(Endpoint.class)
@ConditionalOnProperty(value = "spring.cloud.polaris.config.enabled", matchIfMissing = true) @ConditionalOnPolarisConfigEnabled
public class PolarisConfigEndpointAutoConfiguration { public class PolarisConfigEndpointAutoConfiguration {
@Bean @Bean

@ -33,6 +33,7 @@ import org.springframework.context.annotation.Configuration;
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnBlockingDiscoveryEnabled @ConditionalOnBlockingDiscoveryEnabled
@ConditionalOnPolarisDiscoveryEnabled
@AutoConfigureBefore({ SimpleDiscoveryClientAutoConfiguration.class, CommonsClientAutoConfiguration.class }) @AutoConfigureBefore({ SimpleDiscoveryClientAutoConfiguration.class, CommonsClientAutoConfiguration.class })
@AutoConfigureAfter(PolarisDiscoveryAutoConfiguration.class) @AutoConfigureAfter(PolarisDiscoveryAutoConfiguration.class)
public class PolarisDiscoveryClientConfiguration { public class PolarisDiscoveryClientConfiguration {

@ -19,7 +19,6 @@
package com.tencent.cloud.polaris.registry; package com.tencent.cloud.polaris.registry;
import java.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -54,7 +53,7 @@ public class PolarisRegistration implements Registration {
private Map<String, String> metadata; private Map<String, String> metadata;
private final String host; private String host;
public PolarisRegistration( public PolarisRegistration(
PolarisDiscoveryProperties polarisDiscoveryProperties, PolarisDiscoveryProperties polarisDiscoveryProperties,
@ -78,6 +77,10 @@ public class PolarisRegistration implements Registration {
return host; return host;
} }
public void setHost(String host) {
this.host = host;
}
@Override @Override
public int getPort() { public int getPort() {
return polarisDiscoveryProperties.getPort(); return polarisDiscoveryProperties.getPort();
@ -108,7 +111,7 @@ public class PolarisRegistration implements Registration {
instanceMetadata.putAll(staticMetadataManager.getMergedStaticMetadata()); instanceMetadata.putAll(staticMetadataManager.getMergedStaticMetadata());
this.metadata = Collections.unmodifiableMap(instanceMetadata); this.metadata = instanceMetadata;
} }
return metadata; return metadata;
} }

@ -0,0 +1,38 @@
/*
* 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.polaris.ratelimit.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
/**
* Condition if Polaris rate limit is enabled.
* @author lepdou 2022-09-23
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(name = "spring.cloud.polaris.ratelimit.enabled", matchIfMissing = true)
public @interface ConditionalOnPolarisRateLimitEnabled {
}

@ -18,7 +18,6 @@
package com.tencent.cloud.polaris.ratelimit.config; package com.tencent.cloud.polaris.ratelimit.config;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
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;
import com.tencent.cloud.polaris.ratelimit.RateLimitRuleLabelResolver; import com.tencent.cloud.polaris.ratelimit.RateLimitRuleLabelResolver;
@ -33,7 +32,6 @@ import com.tencent.polaris.ratelimit.factory.LimitAPIFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -53,9 +51,8 @@ import static javax.servlet.DispatcherType.REQUEST;
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled
@AutoConfigureAfter(PolarisContextAutoConfiguration.class) @AutoConfigureAfter(PolarisContextAutoConfiguration.class)
@ConditionalOnProperty(name = "spring.cloud.polaris.ratelimit.enabled", matchIfMissing = true) @ConditionalOnPolarisRateLimitEnabled
public class PolarisRateLimitAutoConfiguration { public class PolarisRateLimitAutoConfiguration {
@Bean @Bean

@ -17,8 +17,6 @@
package com.tencent.cloud.polaris.ratelimit.config; package com.tencent.cloud.polaris.ratelimit.config;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -30,8 +28,8 @@ import org.springframework.context.annotation.Configuration;
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled
@EnableConfigurationProperties(PolarisRateLimitProperties.class) @EnableConfigurationProperties(PolarisRateLimitProperties.class)
@ConditionalOnPolarisRateLimitEnabled
public class PolarisRateLimitPropertiesAutoConfiguration { public class PolarisRateLimitPropertiesAutoConfiguration {
@Bean @Bean

@ -96,7 +96,7 @@ public class PolarisRouterServiceInstanceListSupplier extends DelegatingServiceI
// 2. filter by router // 2. filter by router
DefaultRequestContext requestContext = (DefaultRequestContext) request.getContext(); DefaultRequestContext requestContext = (DefaultRequestContext) request.getContext();
PolarisRouterContext key = null; PolarisRouterContext key;
if (requestContext instanceof RequestDataContext) { if (requestContext instanceof RequestDataContext) {
key = buildRouterContext(((RequestDataContext) requestContext).getClientRequest().getHeaders()); key = buildRouterContext(((RequestDataContext) requestContext).getClientRequest().getHeaders());
} }
@ -104,6 +104,11 @@ public class PolarisRouterServiceInstanceListSupplier extends DelegatingServiceI
key = buildRouterContext(((PolarisLoadBalancerRequest<?>) requestContext.getClientRequest()).getRequest() key = buildRouterContext(((PolarisLoadBalancerRequest<?>) requestContext.getClientRequest()).getRequest()
.getHeaders()); .getHeaders());
} }
else {
// return all servers if router context is null.
return allServers;
}
return doRouter(allServers, key); return doRouter(allServers, key);
} }

@ -0,0 +1,38 @@
/*
* 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.polaris.router.config;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
/**
* Condition if Polaris router is enabled.
* @author lepdou 2022-09-23
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(name = "spring.cloud.polaris.router.enabled", matchIfMissing = true)
public @interface ConditionalOnPolarisRouterEnabled {
}

@ -35,6 +35,7 @@ import org.springframework.lang.Nullable;
* @author lepdou 2022-07-04 * @author lepdou 2022-07-04
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisRouterEnabled
@ConditionalOnClass(name = {"feign.RequestInterceptor"}) @ConditionalOnClass(name = {"feign.RequestInterceptor"})
public class FeignAutoConfiguration { public class FeignAutoConfiguration {

@ -42,6 +42,7 @@ import org.springframework.core.annotation.Order;
* @author lepdou 2022-05-17 * @author lepdou 2022-05-17
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisRouterEnabled
@ConditionalOnDiscoveryEnabled @ConditionalOnDiscoveryEnabled
public class LoadBalancerConfiguration { public class LoadBalancerConfiguration {

@ -55,6 +55,7 @@ import static org.springframework.core.Ordered.HIGHEST_PRECEDENCE;
*@author lepdou 2022-05-11 *@author lepdou 2022-05-11
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisRouterEnabled
@LoadBalancerClients(defaultConfiguration = LoadBalancerConfiguration.class) @LoadBalancerClients(defaultConfiguration = LoadBalancerConfiguration.class)
@Import({PolarisNearByRouterProperties.class, PolarisMetadataRouterProperties.class, PolarisRuleBasedRouterProperties.class}) @Import({PolarisNearByRouterProperties.class, PolarisMetadataRouterProperties.class, PolarisRuleBasedRouterProperties.class})
public class RouterAutoConfiguration { public class RouterAutoConfiguration {

@ -17,6 +17,12 @@
"type": "java.lang.Boolean", "type": "java.lang.Boolean",
"defaultValue": true, "defaultValue": true,
"description": "the switch for rule based router." "description": "the switch for rule based router."
},
{
"name": "spring.cloud.polaris.router.enabled",
"type": "java.lang.Boolean",
"defaultValue": true,
"description": "the switch for router module."
} }
] ]
} }

@ -73,7 +73,7 @@
<revision>1.8.0-2021.0.3-SNAPSHOT</revision> <revision>1.8.0-2021.0.3-SNAPSHOT</revision>
<!-- Dependencies --> <!-- Dependencies -->
<polaris.version>1.8.0-SNAPSHOT</polaris.version> <polaris.version>1.8.0</polaris.version>
<guava.version>31.0.1-jre</guava.version> <guava.version>31.0.1-jre</guava.version>
<logback.version>1.2.11</logback.version> <logback.version>1.2.11</logback.version>
<mocktio.version>4.5.1</mocktio.version> <mocktio.version>4.5.1</mocktio.version>

@ -18,6 +18,8 @@
package com.tencent.cloud.plugin.featureenv; package com.tencent.cloud.plugin.featureenv;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -27,6 +29,7 @@ import org.springframework.context.annotation.Configuration;
* @author lepdou 2022-07-06 * @author lepdou 2022-07-06
*/ */
@Configuration @Configuration
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(value = "spring.cloud.tencent.plugin.router.feature-env.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.cloud.tencent.plugin.router.feature-env.enabled", matchIfMissing = true)
public class FeatureEnvAutoConfiguration { public class FeatureEnvAutoConfiguration {

@ -27,6 +27,8 @@ import com.tencent.cloud.plugin.gateway.staining.rule.RuleStainingExecutor;
import com.tencent.cloud.plugin.gateway.staining.rule.RuleStainingProperties; import com.tencent.cloud.plugin.gateway.staining.rule.RuleStainingProperties;
import com.tencent.cloud.plugin.gateway.staining.rule.RuleTrafficStainer; import com.tencent.cloud.plugin.gateway.staining.rule.RuleTrafficStainer;
import com.tencent.cloud.plugin.gateway.staining.rule.StainingRuleManager; import com.tencent.cloud.plugin.gateway.staining.rule.StainingRuleManager;
import com.tencent.cloud.polaris.config.ConditionalOnPolarisConfigEnabled;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.polaris.configuration.api.core.ConfigFileService; import com.tencent.polaris.configuration.api.core.ConfigFileService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -38,6 +40,7 @@ import org.springframework.context.annotation.Configuration;
* @author lepdou 2022-07-06 * @author lepdou 2022-07-06
*/ */
@Configuration @Configuration
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(value = "spring.cloud.tencent.plugin.scg.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.cloud.tencent.plugin.scg.enabled", matchIfMissing = true)
public class SCGPluginsAutoConfiguration { public class SCGPluginsAutoConfiguration {
@ -52,6 +55,7 @@ public class SCGPluginsAutoConfiguration {
@Configuration @Configuration
@ConditionalOnProperty(value = "spring.cloud.tencent.plugin.scg.staining.rule-staining.enabled", matchIfMissing = true) @ConditionalOnProperty(value = "spring.cloud.tencent.plugin.scg.staining.rule-staining.enabled", matchIfMissing = true)
@ConditionalOnPolarisConfigEnabled
public static class RuleStainingPluginConfiguration { public static class RuleStainingPluginConfiguration {
@Bean @Bean

@ -19,6 +19,7 @@
package com.tencent.cloud.polaris.context.config; package com.tencent.cloud.polaris.context.config;
import com.tencent.cloud.common.metadata.StaticMetadataManager; import com.tencent.cloud.common.metadata.StaticMetadataManager;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.PostInitPolarisSDKContext; import com.tencent.cloud.polaris.context.PostInitPolarisSDKContext;
import com.tencent.polaris.client.api.SDKContext; import com.tencent.polaris.client.api.SDKContext;
@ -31,6 +32,7 @@ import org.springframework.context.annotation.Configuration;
* @author lepdou 2022-06-28 * @author lepdou 2022-06-28
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled
public class PolarisContextPostConfiguration { public class PolarisContextPostConfiguration {
@Bean @Bean

@ -17,6 +17,7 @@
package com.tencent.cloud.polaris.loadbalancer.config; package com.tencent.cloud.polaris.loadbalancer.config;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.loadbalancer.PolarisLoadBalancer; import com.tencent.cloud.polaris.loadbalancer.PolarisLoadBalancer;
import com.tencent.cloud.polaris.loadbalancer.PolarisServiceInstanceListSupplier; import com.tencent.cloud.polaris.loadbalancer.PolarisServiceInstanceListSupplier;
import com.tencent.polaris.router.api.core.RouterAPI; import com.tencent.polaris.router.api.core.RouterAPI;
@ -45,6 +46,7 @@ import org.springframework.core.env.Environment;
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a> * @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled
@ConditionalOnDiscoveryEnabled @ConditionalOnDiscoveryEnabled
public class PolarisLoadBalancerClientConfiguration { public class PolarisLoadBalancerClientConfiguration {

@ -20,6 +20,7 @@ package com.tencent.cloud.rpc.enhancement.config;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration; import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
import com.tencent.cloud.rpc.enhancement.feign.DefaultEnhancedFeignPluginRunner; import com.tencent.cloud.rpc.enhancement.feign.DefaultEnhancedFeignPluginRunner;
import com.tencent.cloud.rpc.enhancement.feign.EnhancedFeignBeanPostProcessor; import com.tencent.cloud.rpc.enhancement.feign.EnhancedFeignBeanPostProcessor;
@ -54,6 +55,7 @@ import org.springframework.web.client.RestTemplate;
* @author <a href="mailto:iskp.me@gmail.com">Palmer.Xu</a> 2022-06-29 * @author <a href="mailto:iskp.me@gmail.com">Palmer.Xu</a> 2022-06-29
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisEnabled
@ConditionalOnProperty(value = "spring.cloud.tencent.rpc-enhancement.enabled", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(value = "spring.cloud.tencent.rpc-enhancement.enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(RpcEnhancementReporterProperties.class) @EnableConfigurationProperties(RpcEnhancementReporterProperties.class)
@AutoConfigureAfter(PolarisContextAutoConfiguration.class) @AutoConfigureAfter(PolarisContextAutoConfiguration.class)

Loading…
Cancel
Save