diff --git a/spring-cloud-starter-tencent-polaris-config/pom.xml b/spring-cloud-starter-tencent-polaris-config/pom.xml
index a7f0e5894..e7262c29f 100644
--- a/spring-cloud-starter-tencent-polaris-config/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-config/pom.xml
@@ -71,6 +71,18 @@
test
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator-autoconfigure
+ true
+
+
org.mockitomockito-inline
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpoint.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpoint.java
new file mode 100644
index 000000000..2ae7b9289
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpoint.java
@@ -0,0 +1,60 @@
+/*
+ * 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 com.tencent.cloud.polaris.config.endpoint;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.tencent.cloud.polaris.config.adapter.PolarisPropertySource;
+import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
+import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
+
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
+
+/**
+ * Endpoint of polaris config.
+ *
+ * @author shuiqingliu
+ **/
+
+@Endpoint(id = "polaris-config")
+public class PolarisConfigEndpoint {
+
+ private PolarisConfigProperties polarisConfigProperties;
+ private PolarisPropertySourceManager polarisPropertySourceManager;
+
+ public PolarisConfigEndpoint(PolarisConfigProperties polarisConfigProperties, PolarisPropertySourceManager polarisPropertySourceManager) {
+ this.polarisConfigProperties = polarisConfigProperties;
+ this.polarisPropertySourceManager = polarisPropertySourceManager;
+ }
+
+ @ReadOperation
+ public Map polarisConfig() {
+ Map configInfo = new HashMap<>();
+ configInfo.put("PolarisConfigProperties", polarisConfigProperties);
+
+ List propertySourceList = polarisPropertySourceManager.getAllPropertySources();
+ configInfo.put("PolarisPropertySource", propertySourceList);
+
+ return configInfo;
+ }
+}
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointAutoConfiguration.java
new file mode 100644
index 000000000..e6271eb35
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointAutoConfiguration.java
@@ -0,0 +1,50 @@
+/*
+ * 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 com.tencent.cloud.polaris.config.endpoint;
+
+import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
+import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
+
+import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * The AutoConfiguration for Polaris Config's endpoint.
+ *
+ * @author shuiqingliu
+ **/
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnClass(Endpoint.class)
+@ConditionalOnProperty(value = "spring.cloud.polaris.config.enabled",
+ matchIfMissing = true)
+public class PolarisConfigEndpointAutoConfiguration {
+
+ @Bean
+ @ConditionalOnAvailableEndpoint
+ @ConditionalOnMissingBean
+ public PolarisConfigEndpoint polarisConfigEndpoint(PolarisConfigProperties polarisConfigProperties, PolarisPropertySourceManager polarisPropertySourceManager) {
+ return new PolarisConfigEndpoint(polarisConfigProperties, polarisPropertySourceManager);
+ }
+}
diff --git a/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/spring.factories b/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/spring.factories
index a0c33067e..98221a39a 100644
--- a/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/spring.factories
+++ b/spring-cloud-starter-tencent-polaris-config/src/main/resources/META-INF/spring.factories
@@ -1,4 +1,5 @@
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
com.tencent.cloud.polaris.config.PolarisConfigBootstrapAutoConfiguration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- com.tencent.cloud.polaris.config.PolarisConfigAutoConfiguration
+ com.tencent.cloud.polaris.config.PolarisConfigAutoConfiguration,\
+ com.tencent.cloud.polaris.config.endpoint.PolarisConfigEndpointAutoConfiguration
diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointTests.java b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointTests.java
new file mode 100644
index 000000000..6dcf10d56
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/endpoint/PolarisConfigEndpointTests.java
@@ -0,0 +1,78 @@
+/*
+ * 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 com.tencent.cloud.polaris.config.endpoint;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.google.common.collect.Lists;
+import com.tencent.cloud.polaris.config.adapter.MockedConfigKVFile;
+import com.tencent.cloud.polaris.config.adapter.PolarisPropertySource;
+import com.tencent.cloud.polaris.config.adapter.PolarisPropertySourceManager;
+import com.tencent.cloud.polaris.config.config.PolarisConfigProperties;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test for polaris config endpoint.
+ *
+ * @author shuiqingliu
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class PolarisConfigEndpointTests {
+
+ private final String testNamespace = "testNamespace";
+ private final String testServiceName = "testServiceName";
+ private final String testFileName = "application.properties";
+
+
+ @Mock
+ private PolarisConfigProperties polarisConfigProperties;
+ @Mock
+ private PolarisPropertySourceManager polarisPropertySourceManager;
+
+ @Test
+ public void polarisConfigEndpoint() {
+ when(polarisConfigProperties.isAutoRefresh()).thenReturn(true);
+
+
+ Map content = new HashMap<>();
+ content.put("k1", "v1");
+ content.put("k2", "v2");
+ content.put("k3", "v3");
+ MockedConfigKVFile file = new MockedConfigKVFile(content);
+ PolarisPropertySource polarisPropertySource = new PolarisPropertySource(testNamespace, testServiceName, testFileName,
+ file, content);
+ when(polarisPropertySourceManager.getAllPropertySources()).thenReturn(Lists.newArrayList(polarisPropertySource));
+
+ PolarisConfigEndpoint endpoint = new PolarisConfigEndpoint(polarisConfigProperties, polarisPropertySourceManager);
+ Map info = endpoint.polarisConfig();
+ assertThat(polarisConfigProperties).isEqualTo(info.get("PolarisConfigProperties"));
+ assertThat(Lists.newArrayList(polarisPropertySource)).isEqualTo(info.get("PolarisPropertySource"));
+
+
+ }
+}
diff --git a/spring-cloud-starter-tencent-polaris-discovery/pom.xml b/spring-cloud-starter-tencent-polaris-discovery/pom.xml
index 39d8d5f83..ac077bb7b 100644
--- a/spring-cloud-starter-tencent-polaris-discovery/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-discovery/pom.xml
@@ -93,6 +93,18 @@
test
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator-autoconfigure
+ true
+
+
io.projectreactorreactor-test
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPoint.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPoint.java
new file mode 100644
index 000000000..f77892c14
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPoint.java
@@ -0,0 +1,72 @@
+/*
+ * 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 com.tencent.cloud.polaris.endpoint;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
+import org.apache.commons.lang.StringUtils;
+
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
+import org.springframework.boot.actuate.endpoint.annotation.Selector;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+
+/**
+ * Endpoint of polaris discovery, include discovery properties and service instance.
+ *
+ * @author shuiqingliu
+ */
+@Endpoint(id = "polaris-discovery")
+public class PolarisDiscoveryEndPoint {
+
+ private PolarisDiscoveryProperties polarisDiscoveryProperties;
+
+ private DiscoveryClient polarisDiscoveryClient;
+
+
+ public PolarisDiscoveryEndPoint(PolarisDiscoveryProperties polarisDiscoveryProperties, DiscoveryClient polarisDiscoveryClient) {
+ this.polarisDiscoveryProperties = polarisDiscoveryProperties;
+ this.polarisDiscoveryClient = polarisDiscoveryClient;
+ }
+
+ @ReadOperation
+ public Map polarisDiscovery(@Selector String serviceId) {
+ Map polarisDisConveryInfo = new HashMap<>();
+ polarisDisConveryInfo.put("PolarisDiscoveryProperties", polarisDiscoveryProperties);
+
+ List serviceInstanceInfoList = Collections.emptyList();
+
+ if (StringUtils.isNotEmpty(serviceId)) {
+ serviceInstanceInfoList = polarisDiscoveryClient.getInstances(serviceId);
+ polarisDisConveryInfo.put("ServiceInstance", serviceInstanceInfoList);
+ return polarisDisConveryInfo;
+ }
+
+ for (String service : polarisDiscoveryClient.getServices()) {
+ serviceInstanceInfoList.addAll(polarisDiscoveryClient.getInstances(service));
+ }
+
+ polarisDisConveryInfo.put("ServiceInstance", serviceInstanceInfoList);
+ return polarisDisConveryInfo;
+ }
+}
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndpointAutoConfiguration.java b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndpointAutoConfiguration.java
new file mode 100644
index 000000000..689fe836b
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndpointAutoConfiguration.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.tencent.cloud.polaris.endpoint;
+
+import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
+import com.tencent.cloud.polaris.discovery.ConditionalOnPolarisDiscoveryEnabled;
+
+import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * The AutoConfiguration for Polaris Discovery's Endpoint.
+ *
+ * @author shuiqingliu
+ **/
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnClass(Endpoint.class)
+@ConditionalOnPolarisDiscoveryEnabled
+public class PolarisDiscoveryEndpointAutoConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ @ConditionalOnAvailableEndpoint
+ public PolarisDiscoveryEndPoint polarisDiscoveryEndPoint(PolarisDiscoveryProperties polarisDiscoveryProperties, DiscoveryClient discoveryClient) {
+ return new PolarisDiscoveryEndPoint(polarisDiscoveryProperties, discoveryClient);
+ }
+}
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/spring.factories b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/spring.factories
index 83b8e001f..e8deb25e8 100644
--- a/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/spring.factories
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/main/resources/META-INF/spring.factories
@@ -2,6 +2,7 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration,\
com.tencent.cloud.polaris.discovery.PolarisDiscoveryAutoConfiguration,\
com.tencent.cloud.polaris.ribbon.PolarisDiscoveryRibbonAutoConfiguration,\
- com.tencent.cloud.polaris.registry.PolarisServiceRegistryAutoConfiguration
+ com.tencent.cloud.polaris.registry.PolarisServiceRegistryAutoConfiguration,\
+ com.tencent.cloud.polaris.endpoint.PolarisDiscoveryEndpointAutoConfiguration
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
com.tencent.cloud.polaris.DiscoveryPropertiesBootstrapAutoConfiguration
diff --git a/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPointTests.java b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPointTests.java
new file mode 100644
index 000000000..f54b34a31
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-discovery/src/test/java/com/tencent/cloud/polaris/endpoint/PolarisDiscoveryEndPointTests.java
@@ -0,0 +1,106 @@
+/*
+ * 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 com.tencent.cloud.polaris.endpoint;
+
+import java.util.Map;
+
+import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
+import com.tencent.cloud.polaris.context.PolarisContextAutoConfiguration;
+import com.tencent.cloud.polaris.discovery.PolarisDiscoveryAutoConfiguration;
+import com.tencent.cloud.polaris.discovery.PolarisDiscoveryClient;
+import com.tencent.cloud.polaris.discovery.PolarisDiscoveryClientConfiguration;
+import com.tencent.polaris.test.mock.discovery.NamingServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.springframework.boot.autoconfigure.AutoConfigurations;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+import static com.tencent.polaris.test.common.Consts.NAMESPACE_TEST;
+import static com.tencent.polaris.test.common.Consts.PORT;
+import static com.tencent.polaris.test.common.Consts.SERVICE_PROVIDER;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test for polaris discovery endpoint.
+ *
+ * @author shuiqingliu
+ */
+public class PolarisDiscoveryEndPointTests {
+
+ private static NamingServer namingServer;
+
+ private WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
+ .withConfiguration(AutoConfigurations.of(
+ PolarisContextAutoConfiguration.class,
+ PolarisDiscoveryEndPointTests.PolarisPropertiesConfiguration.class,
+ PolarisDiscoveryClientConfiguration.class,
+ PolarisDiscoveryAutoConfiguration.class,
+ PolarisDiscoveryEndpointAutoConfiguration.class,
+ PolarisContextAutoConfiguration.class))
+ .withPropertyValues("spring.application.name=" + SERVICE_PROVIDER)
+ .withPropertyValues("server.port=" + PORT)
+ .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081")
+ .withPropertyValues(
+ "spring.cloud.polaris.discovery.namespace=" + NAMESPACE_TEST)
+ .withPropertyValues("spring.cloud.polaris.discovery.token=xxxxxx");
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ namingServer = NamingServer.startNamingServer(10081);
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ if (null != namingServer) {
+ namingServer.terminate();
+ }
+ }
+
+
+ @Test
+ public void polarisDiscoveryEndpoint() {
+ this.contextRunner.run(context -> {
+ PolarisDiscoveryProperties polarisDiscoveryProperties = context
+ .getBean(PolarisDiscoveryProperties.class);
+ DiscoveryClient discoveryClient = context
+ .getBean(PolarisDiscoveryClient.class);
+ PolarisDiscoveryEndPoint polarisDiscoveryEndPoint = new PolarisDiscoveryEndPoint(polarisDiscoveryProperties, discoveryClient);
+
+ Map mapInfo = polarisDiscoveryEndPoint.polarisDiscovery("java_provider_test");
+
+ assertThat(polarisDiscoveryProperties).isEqualTo(mapInfo.get("PolarisDiscoveryProperties"));
+
+ });
+ }
+
+
+ @Configuration
+ @EnableAutoConfiguration
+ @EnableDiscoveryClient
+ static class PolarisPropertiesConfiguration {
+
+ }
+
+}
diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/pom.xml b/spring-cloud-starter-tencent-polaris-ratelimit/pom.xml
index aaccef814..d3499deee 100644
--- a/spring-cloud-starter-tencent-polaris-ratelimit/pom.xml
+++ b/spring-cloud-starter-tencent-polaris-ratelimit/pom.xml
@@ -90,6 +90,18 @@
test
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator-autoconfigure
+ true
+
+
org.mockitomockito-inline
diff --git a/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/endpoint/PolarisRateLimitRuleEndpoint.java b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/endpoint/PolarisRateLimitRuleEndpoint.java
new file mode 100644
index 000000000..d26d94348
--- /dev/null
+++ b/spring-cloud-starter-tencent-polaris-ratelimit/src/main/java/com/tencent/cloud/polaris/ratelimit/endpoint/PolarisRateLimitRuleEndpoint.java
@@ -0,0 +1,103 @@
+/*
+ * 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 com.tencent.cloud.polaris.ratelimit.endpoint;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.tencent.cloud.polaris.context.ServiceRuleManager;
+import com.tencent.cloud.polaris.ratelimit.config.PolarisRateLimitProperties;
+import com.tencent.polaris.client.pb.RateLimitProto;
+import com.tencent.polaris.client.pb.RoutingProto;
+import org.apache.commons.lang.StringUtils;
+
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
+import org.springframework.boot.actuate.endpoint.annotation.Selector;
+import org.springframework.lang.Nullable;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * Endpoint of Polaris RateLimit rule.
+ *
+ * @author shuiqingliu
+ **/
+
+@Endpoint(id = "ratelimit")
+public class PolarisRateLimitRuleEndpoint {
+
+ private ServiceRuleManager serviceRuleManager;
+
+ private PolarisRateLimitProperties polarisRateLimitProperties;
+
+ public PolarisRateLimitRuleEndpoint(ServiceRuleManager serviceRuleManager, PolarisRateLimitProperties polarisRateLimitProperties) {
+ this.serviceRuleManager = serviceRuleManager;
+ this.polarisRateLimitProperties = polarisRateLimitProperties;
+ }
+
+ @ReadOperation
+ public Map rateLimit(@Selector String namespace, @Selector String service, @Nullable String dstService) {
+ Map result = new HashMap<>();
+ RateLimitProto.RateLimit rateLimit = serviceRuleManager.getServiceRateLimitRule(namespace, service);
+ result.put("properties", polarisRateLimitProperties);
+ result.put("namespace", namespace);
+ result.put("service", service);
+ result.put("rateLimits", parseRateLimitRule(rateLimit));
+
+ if (StringUtils.isEmpty(dstService)) {
+ return result;
+ }
+ List routes = serviceRuleManager.getServiceRouterRule(namespace, service, dstService);
+ result.put("routes", routes);
+ return result;
+ }
+
+ private List
+
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator-autoconfigure
+ true
+
diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpoint.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpoint.java
new file mode 100644
index 000000000..019a82e57
--- /dev/null
+++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpoint.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.tencent.cloud.common.metadata.endpoint;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.tencent.cloud.common.metadata.StaticMetadataManager;
+
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
+
+/**
+ * Endpoint of metadata.
+ *
+ * @author shuiqingliu
+ **/
+
+@Endpoint(id = "metadata")
+public class MetadataEndpoint {
+
+ private final StaticMetadataManager staticMetadataManager;
+
+ public MetadataEndpoint(StaticMetadataManager staticMetadataManager) {
+ this.staticMetadataManager = staticMetadataManager;
+ }
+
+ @ReadOperation
+ public Map metadate() {
+ Map result = new HashMap<>();
+ result.put("Env", staticMetadataManager.getAllEnvMetadata());
+ result.put("EnvTransitive", staticMetadataManager.getEnvTransitiveMetadata());
+ result.put("ConfigTransitive", staticMetadataManager.getConfigTransitiveMetadata());
+ result.put("Config", staticMetadataManager.getAllConfigMetadata());
+ result.put("MergeStatic", staticMetadataManager.getMergedStaticMetadata());
+ result.put("zone", staticMetadataManager.getZone());
+ result.put("region", staticMetadataManager.getRegion());
+ result.put("campus", staticMetadataManager.getCampus());
+ return result;
+ }
+}
diff --git a/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointAutoConfiguration.java b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointAutoConfiguration.java
new file mode 100644
index 000000000..018789032
--- /dev/null
+++ b/spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointAutoConfiguration.java
@@ -0,0 +1,47 @@
+/*
+ * 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 com.tencent.cloud.common.metadata.endpoint;
+
+
+import com.tencent.cloud.common.metadata.StaticMetadataManager;
+
+import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
+import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * The AutoConfiguration for metadata endpoint.
+ *
+ * @author shuiqingliu
+ **/
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnClass(Endpoint.class)
+public class MetadataEndpointAutoConfiguration {
+
+
+ @Bean
+ @ConditionalOnMissingBean
+ @ConditionalOnAvailableEndpoint
+ public MetadataEndpoint metadataEndpoint(StaticMetadataManager staticMetadataManager) {
+ return new MetadataEndpoint(staticMetadataManager);
+ }
+}
diff --git a/spring-cloud-tencent-commons/src/main/resources/META-INF/spring.factories b/spring-cloud-tencent-commons/src/main/resources/META-INF/spring.factories
index ba9f2b867..a7c8e90b8 100644
--- a/spring-cloud-tencent-commons/src/main/resources/META-INF/spring.factories
+++ b/spring-cloud-tencent-commons/src/main/resources/META-INF/spring.factories
@@ -1,3 +1,4 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.tencent.cloud.common.util.ApplicationContextAwareUtils,\
- com.tencent.cloud.common.metadata.config.MetadataAutoConfiguration
+ com.tencent.cloud.common.metadata.config.MetadataAutoConfiguration,\
+ com.tencent.cloud.common.metadata.endpoint.MetadataEndpointAutoConfiguration
diff --git a/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointTests.java b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointTests.java
new file mode 100644
index 000000000..3ca93f5a1
--- /dev/null
+++ b/spring-cloud-tencent-commons/src/test/java/com/tencent/cloud/common/metadata/endpoint/MetadataEndpointTests.java
@@ -0,0 +1,60 @@
+/*
+ * 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 com.tencent.cloud.common.metadata.endpoint;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.tencent.cloud.common.metadata.StaticMetadataManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+/**
+ * Test for polaris metadata endpoint.
+ *
+ * @author shuiqingliu
+ */
+@RunWith(MockitoJUnitRunner.class)
+public class MetadataEndpointTests {
+
+ @Mock
+ private StaticMetadataManager staticMetadataManager;
+
+ @Test
+ public void metadataEndpoint() {
+
+ Map envMetadata = new HashMap<>();
+ envMetadata.put("k1", "v1");
+ envMetadata.put("k2", "v2");
+ envMetadata.put("k3", "v3");
+
+ when(staticMetadataManager.getAllEnvMetadata()).thenReturn(envMetadata);
+
+
+ MetadataEndpoint metadataEndpoint = new MetadataEndpoint(staticMetadataManager);
+ Map metaMap = metadataEndpoint.metadate();
+ assertThat(envMetadata).isEqualTo(metaMap.get("Env"));
+ }
+}
diff --git a/spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service/src/main/resources/bootstrap.yml
index 89d1f233b..ed6733181 100644
--- a/spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service/src/main/resources/bootstrap.yml
+++ b/spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service/src/main/resources/bootstrap.yml
@@ -24,3 +24,9 @@ spring:
# Assigned which metadata key-value will be passed along the link
transitive:
- CUSTOM-METADATA-KEY-TRANSITIVE
+management:
+ endpoints:
+ web:
+ exposure:
+ include:
+ - metadata
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-config-example/pom.xml b/spring-cloud-tencent-examples/polaris-config-example/pom.xml
index cef91e5a3..bb7ef026e 100644
--- a/spring-cloud-tencent-examples/polaris-config-example/pom.xml
+++ b/spring-cloud-tencent-examples/polaris-config-example/pom.xml
@@ -24,6 +24,41 @@
com.tencent.cloudspring-cloud-starter-tencent-polaris-config
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.2.0
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/spring-cloud-tencent-examples/polaris-config-example/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-config-example/src/main/resources/bootstrap.yml
index 38ed7eed0..84e44d4aa 100644
--- a/spring-cloud-tencent-examples/polaris-config-example/src/main/resources/bootstrap.yml
+++ b/spring-cloud-tencent-examples/polaris-config-example/src/main/resources/bootstrap.yml
@@ -12,3 +12,9 @@ spring:
groups:
- name: ${spring.application.name} # group name
files: [ "config/application.properties", "config/bootstrap.yml" ] # config/application.properties takes precedence over config/bootstrap.yml
+management:
+ endpoints:
+ web:
+ exposure:
+ include:
+ - polaris-config
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/src/main/resources/bootstrap.yml
index e9ccc1f29..544193b7e 100644
--- a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/src/main/resources/bootstrap.yml
+++ b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-caller-service/src/main/resources/bootstrap.yml
@@ -32,3 +32,9 @@ spring:
# client:
# serviceUrl:
# defaultZone: http://127.0.0.1:7654/eureka/
+management:
+ endpoints:
+ web:
+ exposure:
+ include:
+ - polaris-discovery
\ No newline at end of file
diff --git a/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/pom.xml b/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/pom.xml
index cd9f48757..586d34a5b 100644
--- a/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/pom.xml
+++ b/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/pom.xml
@@ -28,6 +28,11 @@
spring-cloud-starter-tencent-polaris-ratelimit
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
diff --git a/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/src/main/resources/bootstrap.yml b/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/src/main/resources/bootstrap.yml
index 37c986394..7253a3c0f 100644
--- a/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/src/main/resources/bootstrap.yml
+++ b/spring-cloud-tencent-examples/polaris-ratelimit-example/ratelimit-callee-service/src/main/resources/bootstrap.yml
@@ -12,3 +12,10 @@ spring:
enabled: true
rejectRequestTipsFilePath: reject-tips.html
maxQueuingTime: 500
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include:
+ - ratelimit
\ No newline at end of file