diff --git a/CHANGELOG.md b/CHANGELOG.md index b4a10aafb..35f38c020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Change Log --- +- [feat:fix discovery weight param not set to register request bug](https://github.com/Tencent/spring-cloud-tencent/pull/104) - [Bugfix: fix causing cpu 100% when set ScheduledThreadPoolExecutor corePoolSize=0](https://github.com/Tencent/spring-cloud-tencent/pull/101) - diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java index b494984be..d2b34a958 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/PolarisDiscoveryProperties.java @@ -56,7 +56,7 @@ public class PolarisDiscoveryProperties { * Load balance weight. */ @Value("${spring.cloud.polaris.discovery.weight:#{100}}") - private float weight; + private int weight; /** * Version number. @@ -131,11 +131,11 @@ public class PolarisDiscoveryProperties { this.namespace = namespace; } - public float getWeight() { + public int getWeight() { return weight; } - public void setWeight(float weight) { + public void setWeight(int weight) { this.weight = weight; } diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java index 57f4f6278..4440ed8cc 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisServiceRegistry.java @@ -90,6 +90,7 @@ public class PolarisServiceRegistry implements ServiceRegistry { instanceRegisterRequest.setService(registration.getServiceId()); instanceRegisterRequest.setHost(registration.getHost()); instanceRegisterRequest.setPort(registration.getPort()); + instanceRegisterRequest.setWeight(polarisDiscoveryProperties.getWeight()); instanceRegisterRequest.setToken(polarisDiscoveryProperties.getToken()); if (null != heartbeatExecutor) { instanceRegisterRequest.setTtl(ttl); diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 89021b3d2..6608a3b97 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -50,7 +50,7 @@ }, { "name": "spring.cloud.polaris.weight", - "type": "java.lang.String", + "type": "java.lang.Integer", "defaultValue": 100, "description": "the weight of polaris instance , use to load-balance." }