From e5c54f0ee85d5e1d1714f4ee2d8947e7d99fcef9 Mon Sep 17 00:00:00 2001 From: andrew shan <45474304+andrewshan@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:46:52 +0800 Subject: [PATCH 1/3] fix: fix SDKContext --- .../context/PolarisSDKContextManager.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisSDKContextManager.java b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisSDKContextManager.java index 31b0c3c07..26fe59e6b 100644 --- a/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisSDKContextManager.java +++ b/spring-cloud-tencent-polaris-context/src/main/java/com/tencent/cloud/polaris/context/PolarisSDKContextManager.java @@ -22,6 +22,7 @@ import java.util.Objects; import com.tencent.cloud.polaris.context.config.PolarisContextProperties; +import com.tencent.polaris.api.config.Configuration; import com.tencent.polaris.api.control.Destroyable; import com.tencent.polaris.api.core.ConsumerAPI; import com.tencent.polaris.api.core.LosslessAPI; @@ -229,9 +230,10 @@ public void initService() { } } // init SDKContext - serviceSdkContext = SDKContext.initContextByConfig(properties.configuration(serviceModifierList, + Configuration configuration = properties.configuration(serviceModifierList, () -> environment.getProperty("spring.cloud.client.ip-address"), - () -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0))); + () -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0)); + serviceSdkContext = SDKContext.initContextByConfig(configuration); serviceSdkContext.init(); // init ProviderAPI @@ -269,10 +271,10 @@ public void initService() { } } })); - LOG.info("create Polaris SDK context successfully. properties: {}", properties); + LOG.info("create Polaris SDK context successfully. properties: {}, configuration: {}", properties, configuration); } catch (Throwable throwable) { - LOG.error("create Polaris SDK context failed. properties: {}", properties, throwable); + LOG.error("create Polaris SDK context failed. properties: {}, ", properties, throwable); throw throwable; } } @@ -289,14 +291,15 @@ public void initConfig() { if (null == configSDKContext && CollectionUtils.isNotEmpty(configModifierList)) { try { // init config SDKContext - configSDKContext = SDKContext.initContextByConfig(properties.configuration(configModifierList, + Configuration configuration = properties.configuration(configModifierList, () -> environment.getProperty("spring.cloud.client.ip-address"), - () -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0))); + () -> environment.getProperty("spring.cloud.polaris.local-port", Integer.class, 0)); + configSDKContext = SDKContext.initContextByConfig(configuration); configSDKContext.init(); // add shutdown hook Runtime.getRuntime().addShutdownHook(new Thread(PolarisSDKContextManager::innerConfigDestroy)); - LOG.info("create Polaris config SDK context successfully. properties: {}, ", properties); + LOG.info("create Polaris config SDK context successfully. properties: {}, configuration: {}", properties, configuration); } catch (Throwable throwable) { LOG.error("create Polaris config SDK context failed. properties: {}, ", properties, throwable); From 431b4fced1572c39d0b19da01668c7358d38b865 Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Fri, 28 Jun 2024 09:56:27 +0800 Subject: [PATCH 2/3] feat:support consul service update task. --- CHANGELOG.md | 3 ++- .../registry/PolarisAutoServiceRegistration.java | 5 ----- .../tsf-example/consumer-demo/pom.xml | 12 +++++++++++- .../tsf-example/provider-demo/pom.xml | 12 +++++++++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8f8a6ba..5037529d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,4 +18,5 @@ - [fix:fix the ratelimit bug](https://github.com/Tencent/spring-cloud-tencent/pull/1389) - [feat:add Tencent Cloud TSF support.](https://github.com/Tencent/spring-cloud-tencent/pull/1391) - [feat:support consul config.](https://github.com/Tencent/spring-cloud-tencent/pull/1394) -- [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1396) \ No newline at end of file +- [feat:add trace report support.](https://github.com/Tencent/spring-cloud-tencent/pull/1396) +- [feat:support consul service update task.](https://github.com/Tencent/spring-cloud-tencent/pull/1397) \ No newline at end of file diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java index 1c81588ac..c7dad59f8 100644 --- a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java +++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/registry/PolarisAutoServiceRegistration.java @@ -17,9 +17,7 @@ package com.tencent.cloud.polaris.registry; -import com.tencent.cloud.common.metadata.MetadataContext; import com.tencent.cloud.polaris.PolarisDiscoveryProperties; -import com.tencent.polaris.api.pojo.ServiceKey; import com.tencent.polaris.assembly.api.AssemblyAPI; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,9 +71,6 @@ protected void register() { log.debug("Registration disabled."); return; } - if (assemblyAPI != null) { - assemblyAPI.initService(new ServiceKey(MetadataContext.LOCAL_NAMESPACE, MetadataContext.LOCAL_SERVICE)); - } super.register(); } diff --git a/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml b/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml index ca0dc4358..6c839dd70 100644 --- a/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml +++ b/spring-cloud-tencent-examples/tsf-example/consumer-demo/pom.xml @@ -14,7 +14,17 @@ com.tencent.cloud - spring-cloud-starter-tencent-all + spring-cloud-starter-tencent-polaris-discovery + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-config + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-contract diff --git a/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml b/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml index 202b268a8..f5ed608fc 100644 --- a/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml +++ b/spring-cloud-tencent-examples/tsf-example/provider-demo/pom.xml @@ -14,7 +14,17 @@ com.tencent.cloud - spring-cloud-starter-tencent-all + spring-cloud-starter-tencent-polaris-discovery + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-config + + + + com.tencent.cloud + spring-cloud-starter-tencent-polaris-contract From 4905d45a10a1b4be7eb4e0aeefcb8e609935b99a Mon Sep 17 00:00:00 2001 From: Haotian Zhang Date: Fri, 28 Jun 2024 09:56:27 +0800 Subject: [PATCH 3/3] feat:support consul service update task. (#1329) --- spring-cloud-tencent-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-tencent-dependencies/pom.xml b/spring-cloud-tencent-dependencies/pom.xml index 98c855809..e761f1220 100644 --- a/spring-cloud-tencent-dependencies/pom.xml +++ b/spring-cloud-tencent-dependencies/pom.xml @@ -74,7 +74,7 @@ 1.14.0-2020.0.6-SNAPSHOT - 1.15.7-SNAPSHOT + 1.15.8-SNAPSHOT 32.0.1-jre