diff --git a/pom.xml b/pom.xml
index c6e8bd4cb..c4dc08277 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,7 @@
spring-cloud-tencent-examples
spring-cloud-tencent-coverage
spring-cloud-starter-tencent-polaris-config
+ spring-cloud-tencent-polaris-loadbalancer
@@ -77,7 +78,7 @@
- 1.3.0-2020.0.5
+ 1.4.1-2020.0.5-SNAPSHOT
2020.0.5
diff --git a/spring-cloud-starter-tencent-polaris-circuitbreaker/pom.xml b/spring-cloud-starter-tencent-polaris-circuitbreaker/pom.xml
index 354285e59..06286c65d 100644
--- a/spring-cloud-starter-tencent-polaris-circuitbreaker/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-circuitbreaker/pom.xml
@@ -16,7 +16,7 @@
com.tencent.cloud
- spring-cloud-tencent-polaris-context
+ spring-cloud-tencent-polaris-loadbalancer
@@ -84,12 +84,6 @@
-
- org.springframework.cloud
- spring-cloud-loadbalancer
- true
-
-
org.springframework.cloud
spring-cloud-starter-openfeign
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryHandler.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryHandler.java
index b2196cb60..0ea9bb973 100644
--- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryHandler.java
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisDiscoveryHandler.java
@@ -28,6 +28,7 @@ import com.tencent.polaris.api.core.ConsumerAPI;
import com.tencent.polaris.api.core.ProviderAPI;
import com.tencent.polaris.api.pojo.ServiceInfo;
import com.tencent.polaris.api.rpc.GetAllInstancesRequest;
+import com.tencent.polaris.api.rpc.GetHealthyInstancesRequest;
import com.tencent.polaris.api.rpc.GetInstancesRequest;
import com.tencent.polaris.api.rpc.GetServicesRequest;
import com.tencent.polaris.api.rpc.InstancesResponse;
@@ -59,6 +60,7 @@ public class PolarisDiscoveryHandler {
* @param service service name
* @return list of instances
*/
+ @Deprecated
public InstancesResponse getFilteredInstances(String service) {
String namespace = polarisDiscoveryProperties.getNamespace();
GetInstancesRequest getInstancesRequest = new GetInstancesRequest();
@@ -80,6 +82,19 @@ public class PolarisDiscoveryHandler {
return polarisConsumer.getInstances(getInstancesRequest);
}
+ /**
+ * Get a list of healthy instances.
+ * @param service service name
+ * @return list of healthy instances
+ */
+ public InstancesResponse getHealthyInstances(String service) {
+ String namespace = polarisDiscoveryProperties.getNamespace();
+ GetHealthyInstancesRequest getHealthyInstancesRequest = new GetHealthyInstancesRequest();
+ getHealthyInstancesRequest.setNamespace(namespace);
+ getHealthyInstancesRequest.setService(service);
+ return polarisConsumer.getHealthyInstancesInstance(getHealthyInstancesRequest);
+ }
+
/**
* Return all instances for the given service.
* @param service serviceName
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisServiceDiscovery.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisServiceDiscovery.java
index ccaf2f370..044af8634 100644
--- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisServiceDiscovery.java
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/discovery/PolarisServiceDiscovery.java
@@ -49,7 +49,7 @@ public class PolarisServiceDiscovery {
*/
public List getInstances(String serviceId) throws PolarisException {
List instances = new ArrayList<>();
- InstancesResponse filteredInstances = polarisDiscoveryHandler.getFilteredInstances(serviceId);
+ InstancesResponse filteredInstances = polarisDiscoveryHandler.getHealthyInstances(serviceId);
ServiceInstances serviceInstances = filteredInstances.toServiceInstances();
for (Instance instance : serviceInstances.getInstances()) {
instances.add(new PolarisServiceInstance(instance));
diff --git a/spring-cloud-starter-tencent-polaris-router/pom.xml b/spring-cloud-starter-tencent-polaris-router/pom.xml
index 945bcc110..d623da7b1 100644
--- a/spring-cloud-starter-tencent-polaris-router/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-router/pom.xml
@@ -17,79 +17,16 @@
com.tencent.cloud
- spring-cloud-tencent-polaris-context
+ spring-cloud-tencent-polaris-loadbalancer
-
- org.springframework.cloud
- spring-cloud-loadbalancer
-
-
-
- com.tencent.polaris
- polaris-router-factory
-
-
- com.tencent.polaris
- router-rule
-
-
- com.tencent.polaris
- router-nearby
-
-
- com.tencent.polaris
- router-metadata
-
-
- com.tencent.polaris
- router-canary
-
-
- com.tencent.polaris
- router-set
-
-
- com.tencent.polaris
- router-isolated
-
-
- com.tencent.polaris
- router-healthy
-
-
-
-
-
com.tencent.polaris
router-rule
-
-
- com.tencent.polaris
- router-nearby
-
-
-
- com.tencent.polaris
- router-metadata
-
-
-
- com.tencent.polaris
- polaris-test-common
- test
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
+
+
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/package-info.java b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/package-info.java
new file mode 100644
index 000000000..3eb18e376
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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 info of router.
+ *
+ * @author Haotian Zhang
+ */
+package com.tencent.cloud.polaris.router;
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/resources/META-INF/spring.factories b/spring-cloud-starter-tencent-polaris-router/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 76319b269..000000000
--- a/spring-cloud-starter-tencent-polaris-router/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,2 +0,0 @@
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- com.tencent.cloud.polaris.router.config.PolarisLoadBalancerAutoConfiguration
diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java
index 54f203878..54d8b3224 100644
--- a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java
+++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/constant/ContextConstant.java
@@ -24,6 +24,14 @@ package com.tencent.cloud.common.constant;
*/
public final class ContextConstant {
+ /**
+ * Name of Polaris.
+ */
+ public static final String POLARIS = "POLARIS";
+
+ private ContextConstant() {
+ }
+
/**
* Order of configuration modifier.
*/
diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml
index 114e29628..bbbea557b 100644
--- a/spring-cloud-tencent-dependencies/pom.xml
+++ b/spring-cloud-tencent-dependencies/pom.xml
@@ -70,8 +70,8 @@
- 1.3.0-2020.0.5
- 1.4.0
+ 1.4.1-2020.0.5-SNAPSHOT
+ 1.5.1
2.0.0
@@ -102,6 +102,12 @@
${revision}
+
+ com.tencent.cloud
+ spring-cloud-tencent-polaris-loadbalancer
+ ${revision}
+
+
com.tencent.cloud
spring-cloud-starter-tencent-metadata-transfer
diff --git a/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/pom.xml b/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/pom.xml
index 837fdfba7..9833b5f88 100644
--- a/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/pom.xml
+++ b/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/pom.xml
@@ -33,6 +33,11 @@
org.springframework.cloud
spring-cloud-starter-loadbalancer
+
+
+ org.springframework.cloud
+ spring-cloud-circuitbreaker-spring-retry
+
diff --git a/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/src/main/resources/bootstrap.yml
index e693a9700..ba762ac58 100644
--- a/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/src/main/resources/bootstrap.yml
+++ b/spring-cloud-tencent-examples/polaris-circuitbreaker-example/polaris-circuitbreaker-example-a/src/main/resources/bootstrap.yml
@@ -10,6 +10,8 @@ spring:
enabled: true
circuitbreaker:
enabled: true
+ loadbalancer:
+ configurations: polaris
feign:
circuitbreaker:
enabled: true
diff --git a/spring-cloud-tencent-polaris-context/pom.xml b/spring-cloud-tencent-polaris-context/pom.xml
index a63d20264..aa9b8523b 100644
--- a/spring-cloud-tencent-polaris-context/pom.xml
+++ b/spring-cloud-tencent-polaris-context/pom.xml
@@ -35,32 +35,32 @@
com.tencent.polaris
polaris-plugin-api
-
+
-
- com.tencent.polaris
- connector-polaris-grpc
-
+
+ com.tencent.polaris
+ connector-polaris-grpc
+
-
- com.tencent.polaris
- connector-consul
-
+
+ com.tencent.polaris
+ connector-consul
+
-
- com.tencent.polaris
- connector-composite
-
+
+ com.tencent.polaris
+ connector-composite
+
-
- com.tencent.polaris
- registry-memory
-
+
+ com.tencent.polaris
+ registry-memory
+
-
- com.tencent.polaris
- flow-cache-expired
-
+
+ com.tencent.polaris
+ flow-cache-expired
+
@@ -72,23 +72,23 @@
com.tencent.polaris
router-healthy
-
-
- com.tencent.polaris
- loadbalancer-random
-
-
-
- com.tencent.polaris
- loadbalancer-ringhash
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
+
+
+ com.tencent.polaris
+ loadbalancer-random
+
+
+
+ com.tencent.polaris
+ loadbalancer-ringhash
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
diff --git a/spring-cloud-tencent-polaris-loadbalancer/pom.xml b/spring-cloud-tencent-polaris-loadbalancer/pom.xml
new file mode 100644
index 000000000..cfec39a05
--- /dev/null
+++ b/spring-cloud-tencent-polaris-loadbalancer/pom.xml
@@ -0,0 +1,54 @@
+
+
+
+ spring-cloud-tencent
+ com.tencent.cloud
+ ${revision}
+ ../pom.xml
+
+ 4.0.0
+
+ spring-cloud-tencent-polaris-loadbalancer
+ Spring Cloud Tencent Polaris LoadBalancer
+
+
+
+
+ com.tencent.cloud
+ spring-cloud-tencent-polaris-context
+
+
+
+
+
+ com.tencent.polaris
+ polaris-router-factory
+
+
+
+ com.tencent.polaris
+ polaris-discovery-api
+
+
+
+ com.tencent.polaris
+ polaris-test-common
+ test
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-loadbalancer
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
\ No newline at end of file
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadbalancer.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisLoadbalancer.java
similarity index 90%
rename from spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadbalancer.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisLoadbalancer.java
index 983543d3b..e76098355 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRoutingLoadbalancer.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisLoadbalancer.java
@@ -15,14 +15,14 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router;
+package com.tencent.cloud.polaris.loadbalancer;
import java.util.List;
import java.util.stream.Collectors;
import com.tencent.cloud.common.metadata.MetadataContext;
import com.tencent.cloud.common.pojo.PolarisServiceInstance;
-import com.tencent.cloud.polaris.router.config.PolarisLoadBalancerProperties;
+import com.tencent.cloud.polaris.loadbalancer.config.PolarisLoadBalancerProperties;
import com.tencent.polaris.api.pojo.DefaultServiceInstances;
import com.tencent.polaris.api.pojo.Instance;
import com.tencent.polaris.api.pojo.ServiceInstances;
@@ -51,9 +51,9 @@ import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
*
* @author liaochuntao
*/
-public class PolarisRoutingLoadbalancer extends RoundRobinLoadBalancer implements ReactorServiceInstanceLoadBalancer {
+public class PolarisLoadbalancer extends RoundRobinLoadBalancer implements ReactorServiceInstanceLoadBalancer {
- private static final Logger log = LoggerFactory.getLogger(PolarisRoutingLoadbalancer.class);
+ private static final Logger log = LoggerFactory.getLogger(PolarisLoadbalancer.class);
private final String serviceId;
@@ -63,8 +63,7 @@ public class PolarisRoutingLoadbalancer extends RoundRobinLoadBalancer implement
private ObjectProvider supplierObjectProvider;
- public PolarisRoutingLoadbalancer(String serviceId,
- ObjectProvider supplierObjectProvider,
+ public PolarisLoadbalancer(String serviceId, ObjectProvider supplierObjectProvider,
PolarisLoadBalancerProperties loadBalancerProperties, RouterAPI routerAPI) {
super(supplierObjectProvider, serviceId);
this.serviceId = serviceId;
@@ -83,7 +82,7 @@ public class PolarisRoutingLoadbalancer extends RoundRobinLoadBalancer implement
@Override
public Mono> choose(Request request) {
- if (!loadBalancerProperties.getLoadbalancerEnabled()) {
+ if (!loadBalancerProperties.getEnabled()) {
return super.choose(request);
}
ServiceInstanceListSupplier supplier = supplierObjectProvider
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRouterServiceInstanceListSupplier.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisServiceInstanceListSupplier.java
similarity index 94%
rename from spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRouterServiceInstanceListSupplier.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisServiceInstanceListSupplier.java
index b9866d5df..20dd8c60d 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/PolarisRouterServiceInstanceListSupplier.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/PolarisServiceInstanceListSupplier.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router;
+package com.tencent.cloud.polaris.loadbalancer;
import java.util.ArrayList;
import java.util.List;
@@ -48,11 +48,11 @@ import org.springframework.util.CollectionUtils;
*
* @author Haotian Zhang
*/
-public class PolarisRouterServiceInstanceListSupplier extends DelegatingServiceInstanceListSupplier {
+public class PolarisServiceInstanceListSupplier extends DelegatingServiceInstanceListSupplier {
private final RouterAPI routerAPI;
- public PolarisRouterServiceInstanceListSupplier(ServiceInstanceListSupplier delegate, RouterAPI routerAPI) {
+ public PolarisServiceInstanceListSupplier(ServiceInstanceListSupplier delegate, RouterAPI routerAPI) {
super(delegate);
this.routerAPI = routerAPI;
}
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfiguration.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
similarity index 97%
rename from spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfiguration.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
index 47c63b57a..70f09fb07 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfiguration.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfiguration.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router.config;
+package com.tencent.cloud.polaris.loadbalancer.config;
import com.tencent.cloud.polaris.context.ConditionalOnPolarisEnabled;
import com.tencent.polaris.api.exception.PolarisException;
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerClientConfiguration.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerClientConfiguration.java
similarity index 92%
rename from spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerClientConfiguration.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerClientConfiguration.java
index 371df6450..8e9cc3d89 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerClientConfiguration.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerClientConfiguration.java
@@ -15,10 +15,10 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router.config;
+package com.tencent.cloud.polaris.loadbalancer.config;
-import com.tencent.cloud.polaris.router.PolarisRouterServiceInstanceListSupplier;
-import com.tencent.cloud.polaris.router.PolarisRoutingLoadbalancer;
+import com.tencent.cloud.polaris.loadbalancer.PolarisLoadbalancer;
+import com.tencent.cloud.polaris.loadbalancer.PolarisServiceInstanceListSupplier;
import com.tencent.polaris.router.api.core.RouterAPI;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -59,7 +59,7 @@ public class PolarisLoadBalancerClientConfiguration {
LoadBalancerClientFactory loadBalancerClientFactory, PolarisLoadBalancerProperties loadBalancerProperties,
RouterAPI routerAPI) {
String name = environment.getProperty(LoadBalancerClientFactory.PROPERTY_NAME);
- return new PolarisRoutingLoadbalancer(name,
+ return new PolarisLoadbalancer(name,
loadBalancerClientFactory.getLazyProvider(name, ServiceInstanceListSupplier.class),
loadBalancerProperties, routerAPI);
}
@@ -74,7 +74,7 @@ public class PolarisLoadBalancerClientConfiguration {
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.configurations", havingValue = "polaris")
public ServiceInstanceListSupplier polarisRouterDiscoveryClientServiceInstanceListSupplier(RouterAPI routerAPI,
ConfigurableApplicationContext context) {
- return new PolarisRouterServiceInstanceListSupplier(
+ return new PolarisServiceInstanceListSupplier(
ServiceInstanceListSupplier.builder().withDiscoveryClient().build(context), routerAPI);
}
@@ -90,7 +90,7 @@ public class PolarisLoadBalancerClientConfiguration {
@ConditionalOnProperty(value = "spring.cloud.loadbalancer.configurations", havingValue = "polaris")
public ServiceInstanceListSupplier polarisRouterDiscoveryClientServiceInstanceListSupplier(RouterAPI routerAPI,
ConfigurableApplicationContext context) {
- return new PolarisRouterServiceInstanceListSupplier(
+ return new PolarisServiceInstanceListSupplier(
ServiceInstanceListSupplier.builder().withBlockingDiscoveryClient().build(context), routerAPI);
}
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerProperties.java b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerProperties.java
similarity index 59%
rename from spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerProperties.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerProperties.java
index 9acada22f..e8feb88af 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/main/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerProperties.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerProperties.java
@@ -15,30 +15,34 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router.config;
+package com.tencent.cloud.polaris.loadbalancer.config;
+
+import com.tencent.cloud.common.constant.ContextConstant;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
- * Properties of loadbalancer.
+ * Properties of Polaris loadbalancer.
*
* @author Haotian Zhang
*/
-@ConfigurationProperties("spring.cloud.polaris.ribbon")
+@ConfigurationProperties("spring.cloud.polaris.loadbalancer")
public class PolarisLoadBalancerProperties {
/**
* If load-balance enabled.
*/
- @Value("${spring.cloud.polaris.discovery.loadbalancer.enabled:#{true}}")
- private Boolean loadbalancerEnabled;
+ private Boolean enabled = true;
/**
* Load balance strategy.
*/
- @Value("${spring.cloud.polaris.loadbalancer.strategy:#{'weightedRandom'}}")
- private String strategy;
+ private String strategy = "weightedRandom";
+
+ /**
+ * Type of discovery server.
+ */
+ private String discoveryType = ContextConstant.POLARIS;
public String getStrategy() {
return strategy;
@@ -48,18 +52,26 @@ public class PolarisLoadBalancerProperties {
this.strategy = strategy;
}
- public Boolean getLoadbalancerEnabled() {
- return loadbalancerEnabled;
+ public Boolean getEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getDiscoveryType() {
+ return discoveryType;
}
- public void setLoadbalancerEnabled(Boolean loadbalancerEnabled) {
- this.loadbalancerEnabled = loadbalancerEnabled;
+ public void setDiscoveryType(String discoveryType) {
+ this.discoveryType = discoveryType;
}
@Override
public String toString() {
- return "PolarisRibbonProperties{" + "loadbalancerEnabled=" + loadbalancerEnabled + ", strategy='" + strategy
- + '\'' + '}';
+ return "PolarisLoadBalancerProperties{" + "loadbalancerEnabled=" + enabled + ", strategy='" + strategy + '\''
+ + '}';
}
}
diff --git a/spring-cloud-starter-tencent-polaris-router/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-tencent-polaris-loadbalancer/src/main/resources/META-INF/additional-spring-configuration-metadata.json
similarity index 100%
rename from spring-cloud-starter-tencent-polaris-router/src/main/resources/META-INF/additional-spring-configuration-metadata.json
rename to spring-cloud-tencent-polaris-loadbalancer/src/main/resources/META-INF/additional-spring-configuration-metadata.json
diff --git a/spring-cloud-tencent-polaris-loadbalancer/src/main/resources/META-INF/spring.factories b/spring-cloud-tencent-polaris-loadbalancer/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..a13924bac
--- /dev/null
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+ com.tencent.cloud.polaris.loadbalancer.config.PolarisLoadBalancerAutoConfiguration
diff --git a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfigurationTest.java b/spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfigurationTest.java
similarity index 97%
rename from spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfigurationTest.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfigurationTest.java
index 7c96a8a87..fb7b896c7 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisLoadBalancerAutoConfigurationTest.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisLoadBalancerAutoConfigurationTest.java
@@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router.config;
+package com.tencent.cloud.polaris.loadbalancer.config;
import com.tencent.cloud.polaris.context.PolarisContextAutoConfiguration;
import com.tencent.polaris.router.api.core.RouterAPI;
diff --git a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisRouterAutoConfigurationTest.java b/spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisRouterAutoConfigurationTest.java
similarity index 91%
rename from spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisRouterAutoConfigurationTest.java
rename to spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisRouterAutoConfigurationTest.java
index a29bd7f3c..2593095a8 100644
--- a/spring-cloud-starter-tencent-polaris-router/src/test/java/com/tencent/cloud/polaris/router/config/PolarisRouterAutoConfigurationTest.java
+++ b/spring-cloud-tencent-polaris-loadbalancer/src/test/java/com/tencent/cloud/polaris/loadbalancer/config/PolarisRouterAutoConfigurationTest.java
@@ -15,10 +15,10 @@
* specific language governing permissions and limitations under the License.
*/
-package com.tencent.cloud.polaris.router.config;
+package com.tencent.cloud.polaris.loadbalancer.config;
import com.tencent.cloud.polaris.context.PolarisContextAutoConfiguration;
-import com.tencent.cloud.polaris.router.PolarisRouterServiceInstanceListSupplier;
+import com.tencent.cloud.polaris.loadbalancer.PolarisServiceInstanceListSupplier;
import com.tencent.polaris.router.api.core.RouterAPI;
import org.junit.Test;
@@ -59,7 +59,7 @@ public class PolarisRouterAutoConfigurationTest {
.doesNotHaveBean(PolarisLoadBalancerClientConfiguration.PolarisReactiveSupportConfiguration.class);
assertThat(context)
.hasSingleBean(PolarisLoadBalancerClientConfiguration.PolarisBlockingSupportConfiguration.class);
- assertThat(context).doesNotHaveBean(PolarisRouterServiceInstanceListSupplier.class);
+ assertThat(context).doesNotHaveBean(PolarisServiceInstanceListSupplier.class);
});
}
@@ -75,7 +75,7 @@ public class PolarisRouterAutoConfigurationTest {
.doesNotHaveBean(PolarisLoadBalancerClientConfiguration.PolarisReactiveSupportConfiguration.class);
assertThat(context)
.hasSingleBean(PolarisLoadBalancerClientConfiguration.PolarisBlockingSupportConfiguration.class);
- assertThat(context).doesNotHaveBean(PolarisRouterServiceInstanceListSupplier.class);
+ assertThat(context).doesNotHaveBean(PolarisServiceInstanceListSupplier.class);
});
}