# Conflicts: # CHANGELOG.md # spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/PolarisConfigAutoConfiguration.java # spring-cloud-starter-tencent-polaris-config/src/main/java/com/tencent/cloud/polaris/config/adapter/PolarisPropertySourceAutoRefresher.java # spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/adapter/PolarisPropertiesSourceAutoRefresherTest.java # spring-cloud-tencent-commons/src/main/java/com/tencent/cloud/common/util/JacksonUtils.javapull/326/head
@ -0,0 +1,4 @@
|
|||||||
|
# Change Log
|
||||||
|
---
|
||||||
|
|
||||||
|
- [fix not load application.yml bug & fix guava version conflict bug](https://github.com/Tencent/spring-cloud-tencent/pull/284)
|
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.7 KiB |
18
spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/intercepter/EncodeTransferMedataRestTemplateInterceptorTest.java → spring-cloud-starter-tencent-metadata-transfer/src/test/java/com/tencent/cloud/metadata/core/EncodeTransferMedataRestTemplateInterceptorTest.java
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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.circuitbreaker;
|
||||||
|
|
||||||
|
import com.tencent.cloud.polaris.circuitbreaker.config.PolarisRestTemplateAutoConfiguration;
|
||||||
|
import com.tencent.cloud.polaris.circuitbreaker.resttemplate.PolarisRestTemplateModifier;
|
||||||
|
import com.tencent.cloud.polaris.circuitbreaker.resttemplate.PolarisRestTemplateResponseErrorHandler;
|
||||||
|
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test For {@link PolarisRestTemplateAutoConfiguration} .
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:iskp.me@gmail.com">Palmer Xu</a> 2022-06-28
|
||||||
|
*/
|
||||||
|
public class PolarisRestTemplateAutoConfigurationTest {
|
||||||
|
|
||||||
|
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
|
||||||
|
.withConfiguration(AutoConfigurations.of(
|
||||||
|
PolarisRestTemplateAutoConfigurationTester.class,
|
||||||
|
PolarisContextAutoConfiguration.class,
|
||||||
|
PolarisRestTemplateAutoConfiguration.class))
|
||||||
|
.withPropertyValues("spring.cloud.polaris.circuitbreaker.enabled=true");
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitialization() {
|
||||||
|
this.contextRunner
|
||||||
|
.run(context -> {
|
||||||
|
assertThat(context).hasSingleBean(PolarisRestTemplateModifier.class);
|
||||||
|
assertThat(context).hasSingleBean(PolarisRestTemplateResponseErrorHandler.class);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableAutoConfiguration
|
||||||
|
@AutoConfigureBefore(PolarisRestTemplateAutoConfiguration.class)
|
||||||
|
static class PolarisRestTemplateAutoConfigurationTester {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/PolarisRestTemplateResponseErrorHandlerTest.java → spring-cloud-starter-tencent-polaris-circuitbreaker/src/test/java/com/tencent/cloud/polaris/circuitbreaker/resttemplate/PolarisRestTemplateResponseErrorHandlerTest.java
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 final PolarisConfigProperties polarisConfigProperties;
|
||||||
|
private final PolarisPropertySourceManager polarisPropertySourceManager;
|
||||||
|
|
||||||
|
public PolarisConfigEndpoint(PolarisConfigProperties polarisConfigProperties, PolarisPropertySourceManager polarisPropertySourceManager) {
|
||||||
|
this.polarisConfigProperties = polarisConfigProperties;
|
||||||
|
this.polarisPropertySourceManager = polarisPropertySourceManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReadOperation
|
||||||
|
public Map<String, Object> polarisConfig() {
|
||||||
|
Map<String, Object> configInfo = new HashMap<>();
|
||||||
|
configInfo.put("PolarisConfigProperties", polarisConfigProperties);
|
||||||
|
|
||||||
|
List<PolarisPropertySource> propertySourceList = polarisPropertySourceManager.getAllPropertySources();
|
||||||
|
configInfo.put("PolarisPropertySource", propertySourceList);
|
||||||
|
|
||||||
|
return configInfo;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
|
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
|
||||||
com.tencent.cloud.polaris.config.PolarisConfigBootstrapAutoConfiguration
|
com.tencent.cloud.polaris.config.PolarisConfigBootstrapAutoConfiguration
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.tencent.cloud.polaris.config.PolarisConfigAutoConfiguration
|
com.tencent.cloud.polaris.config.PolarisConfigAutoConfiguration,\
|
||||||
|
com.tencent.cloud.polaris.config.endpoint.PolarisConfigEndpointAutoConfiguration
|
||||||
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* 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 PolarisConfigEndpointTest {
|
||||||
|
|
||||||
|
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 testPolarisConfigEndpoint() {
|
||||||
|
Map<String, Object> 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<String, Object> info = endpoint.polarisConfig();
|
||||||
|
assertThat(polarisConfigProperties).isEqualTo(info.get("PolarisConfigProperties"));
|
||||||
|
assertThat(Lists.newArrayList(polarisPropertySource)).isEqualTo(info.get("PolarisPropertySource"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.tencent.cloud.polaris.PolarisDiscoveryProperties;
|
||||||
|
import com.tencent.cloud.polaris.discovery.PolarisDiscoveryHandler;
|
||||||
|
import com.tencent.polaris.api.pojo.ServiceInstances;
|
||||||
|
import com.tencent.polaris.api.rpc.InstancesResponse;
|
||||||
|
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.discovery.DiscoveryClient;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Endpoint of polaris discovery, include discovery properties and service instance.
|
||||||
|
*
|
||||||
|
* @author shuiqingliu
|
||||||
|
*/
|
||||||
|
@Endpoint(id = "polaris-discovery")
|
||||||
|
public class PolarisDiscoveryEndPoint {
|
||||||
|
|
||||||
|
private final PolarisDiscoveryProperties polarisDiscoveryProperties;
|
||||||
|
private final DiscoveryClient polarisDiscoveryClient;
|
||||||
|
private final PolarisDiscoveryHandler polarisDiscoveryHandler;
|
||||||
|
|
||||||
|
public PolarisDiscoveryEndPoint(PolarisDiscoveryProperties polarisDiscoveryProperties, DiscoveryClient polarisDiscoveryClient, PolarisDiscoveryHandler polarisDiscoveryHandler) {
|
||||||
|
this.polarisDiscoveryProperties = polarisDiscoveryProperties;
|
||||||
|
this.polarisDiscoveryClient = polarisDiscoveryClient;
|
||||||
|
this.polarisDiscoveryHandler = polarisDiscoveryHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReadOperation
|
||||||
|
public Map<String, Object> polarisDiscovery(@Selector String serviceId) {
|
||||||
|
Map<String, Object> polarisDisConveryInfo = new HashMap<>();
|
||||||
|
polarisDisConveryInfo.put("PolarisDiscoveryProperties", polarisDiscoveryProperties);
|
||||||
|
|
||||||
|
List<ServiceInstances> serviceInstancesInfoList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (StringUtils.isNotEmpty(serviceId)) {
|
||||||
|
ServiceInstances serviceInstances = getServiceInstances(serviceId);
|
||||||
|
serviceInstancesInfoList.add(serviceInstances);
|
||||||
|
polarisDisConveryInfo.put("ServiceInstances", serviceInstancesInfoList);
|
||||||
|
return polarisDisConveryInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String service : polarisDiscoveryClient.getServices()) {
|
||||||
|
ServiceInstances serviceInstances = getServiceInstances(service);
|
||||||
|
serviceInstancesInfoList.add(serviceInstances);
|
||||||
|
}
|
||||||
|
|
||||||
|
polarisDisConveryInfo.put("ServiceInstances", serviceInstancesInfoList);
|
||||||
|
return polarisDisConveryInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ServiceInstances getServiceInstances(String serviceId) {
|
||||||
|
InstancesResponse instancesResponse = polarisDiscoveryHandler.getHealthyInstances(serviceId);
|
||||||
|
ServiceInstances serviceInstances = instancesResponse.toServiceInstances();
|
||||||
|
return serviceInstances;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.tencent.cloud.polaris.discovery.PolarisDiscoveryHandler;
|
||||||
|
|
||||||
|
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, PolarisDiscoveryHandler polarisDiscoveryHandler) {
|
||||||
|
return new PolarisDiscoveryEndPoint(polarisDiscoveryProperties, discoveryClient, polarisDiscoveryHandler);
|
||||||
|
}
|
||||||
|
}
|