From 48c8922d2893e5fd7a904783d87261b389ec0d17 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Thu, 31 Jul 2025 10:58:19 +0800 Subject: [PATCH] optimize. --- CHANGELOG.md | 12 ++-------- .../polaris/PolarisDiscoveryProperties.java | 16 ++++++++++++- .../registry/PolarisServiceRegistry.java | 23 ++++++++++++------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dcb8ba35..4d87bf025 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,6 @@ # Change Log --- -- [fix: add gateway context config example.](https://github.com/Tencent/spring-cloud-tencent/pull/1563) -- [feat:support config empty protection.](https://github.com/Tencent/spring-cloud-tencent/pull/1585) -- [feat:upgrade springframework version.](https://github.com/Tencent/spring-cloud-tencent/pull/1590) -- [feat:support dynamic multi-discovery.](https://github.com/Tencent/spring-cloud-tencent/pull/1595) -- [feat:support ipv6.](https://github.com/Tencent/spring-cloud-tencent/pull/1598) -- [feat:support config all recover enabled.](https://github.com/Tencent/spring-cloud-tencent/pull/1604) -- [feat:support stat reporting path aggregation.](https://github.com/Tencent/spring-cloud-tencent/pull/1608) -- [feat:support instance detect.](https://github.com/Tencent/spring-cloud-tencent/pull/1617) -- [fix: polaris.discovery.heartbeat.enabled not effective.](https://github.com/Tencent/spring-cloud-tencent/pull/1621) - [fix:fix PolarisContextProperties instantiated twice causing NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/1638) - [feat:support setting load balancing strategy per service.](https://github.com/Tencent/spring-cloud-tencent/pull/1633) - [feat: support tsf 2024.](https://github.com/Tencent/spring-cloud-tencent/pull/1635) @@ -25,4 +16,5 @@ - [fix: fix lb configuration on bootstrap step.](https://github.com/Tencent/spring-cloud-tencent/issues/1673) - [feat:support 2024.0.2.](https://github.com/Tencent/spring-cloud-tencent/issues/1674) - [feat:support fault injection.](https://github.com/Tencent/spring-cloud-tencent/pull/1672) -- [feat: support config event and monitor address list.](https://github.com/Tencent/spring-cloud-tencent/pull/1675) \ No newline at end of file +- [feat: support config event and monitor address list.](https://github.com/Tencent/spring-cloud-tencent/pull/1675) +- [fix: polaris.discovery.heartbeat.enabled not effective.](https://github.com/Tencent/spring-cloud-tencent/pull/1680) 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 7ae401bbc..4eb8d1fe6 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 @@ -83,6 +83,11 @@ public class PolarisDiscoveryProperties { @Value("${spring.cloud.polaris.discovery.register:#{true}}") private Boolean registerEnabled; + /** + * Enable heartbeat or not. + */ + private Boolean heartbeatEnabled = true; + /** * Heartbeat interval ( 0 < interval <= 60). * Time unit: second. Default: 5. @@ -207,7 +212,15 @@ public class PolarisDiscoveryProperties { public void setServiceListRefreshInterval(Long serviceListRefreshInterval) { this.serviceListRefreshInterval = serviceListRefreshInterval; } - + + public Boolean getHeartbeatEnabled() { + return heartbeatEnabled; + } + + public void setHeartbeatEnabled(Boolean heartbeatEnabled) { + this.heartbeatEnabled = heartbeatEnabled; + } + public Integer getHeartbeatInterval() { if (this.heartbeatInterval <= 0 || this.heartbeatInterval > 60) { heartbeatInterval = DEFAULT_REGISTRY_HEARTBEAT_TIME_INTERVAL; @@ -291,6 +304,7 @@ public class PolarisDiscoveryProperties { ", protocol='" + protocol + '\'' + ", enabled=" + enabled + ", registerEnabled=" + registerEnabled + + ", heartbeatEnabled=" + heartbeatEnabled + ", heartbeatInterval=" + heartbeatInterval + ", healthCheckUrl='" + healthCheckUrl + '\'' + ", serviceListRefreshInterval=" + serviceListRefreshInterval + 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 952b7c3be..0c12f0b32 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 @@ -127,7 +127,6 @@ public class PolarisServiceRegistry implements ServiceRegistry