diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b57b739..a663b3d72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,5 @@ --- - [Bugfix: fix router bug and add router example](https://github.com/Tencent/spring-cloud-tencent/pull/89) +- [feat:fix discovery weight param not set to register request bug](https://github.com/Tencent/spring-cloud-tencent/pull/102) 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 35f397217..351ab62f3 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. @@ -134,11 +134,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 7e72a075d..b947db594 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 @@ -95,6 +95,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." }