Merge pull request #68 from SkyeBeFreeman/main

feat:optimize dependencies and notes.
pull/69/head
lepdou 3 years ago committed by GitHub
commit 3994863985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,7 +6,6 @@
- [feat:Support multi-discovery server.](https://github.com/Tencent/spring-cloud-tencent/pull/42) - [feat:Support multi-discovery server.](https://github.com/Tencent/spring-cloud-tencent/pull/42)
- [fix:fix [Deserialization of Untrusted Data in logback]](https://github.com/Tencent/spring-cloud-tencent/pull/44/files) - [fix:fix [Deserialization of Untrusted Data in logback]](https://github.com/Tencent/spring-cloud-tencent/pull/44/files)
- [feat:support customize registered ip address.](https://github.com/Tencent/spring-cloud-tencent/pull/47) - [feat:support customize registered ip address.](https://github.com/Tencent/spring-cloud-tencent/pull/47)
- [https://github.com/Tencent/spring-cloud-tencent/pull/51](https://github.com/Tencent/spring-cloud-tencent/pull/51)
- [fix:fix import default log implement error](https://github.com/Tencent/spring-cloud-tencent/pull/53) - [fix:fix import default log implement error](https://github.com/Tencent/spring-cloud-tencent/pull/53)
- [send heartbeat if healthcheck url not configured](https://github.com/Tencent/spring-cloud-tencent/pull/54) - [send heartbeat if healthcheck url not configured](https://github.com/Tencent/spring-cloud-tencent/pull/54)
- [feat:optimize project structure and checkstyle](https://github.com/Tencent/spring-cloud-tencent/pull/56) - [feat:optimize project structure and checkstyle](https://github.com/Tencent/spring-cloud-tencent/pull/56)

@ -58,7 +58,7 @@ public class MetadataFirstScgFilter implements GlobalFilter, Ordered {
MetadataContext metadataContext = exchange MetadataContext metadataContext = exchange
.getAttribute(MetadataConstant.HeaderName.METADATA_CONTEXT); .getAttribute(MetadataConstant.HeaderName.METADATA_CONTEXT);
// TODO 对端命名空间暂时与本地命名空间相同 // TODO The peer namespace is temporarily the same as the local namespace
metadataContext.putSystemMetadata( metadataContext.putSystemMetadata(
MetadataConstant.SystemMetadataKey.PEER_NAMESPACE, MetadataConstant.SystemMetadataKey.PEER_NAMESPACE,
MetadataContextHolder.get().getSystemMetadata( MetadataContextHolder.get().getSystemMetadata(

@ -53,7 +53,7 @@ public class MetadataFirstZuulFilter extends ZuulFilter {
// get request context // get request context
RequestContext requestContext = RequestContext.getCurrentContext(); RequestContext requestContext = RequestContext.getCurrentContext();
// TODO 对端命名空间暂时与本地命名空间相同 // TODO The peer namespace is temporarily the same as the local namespace
MetadataContextHolder.get().putSystemMetadata( MetadataContextHolder.get().putSystemMetadata(
MetadataConstant.SystemMetadataKey.PEER_NAMESPACE, MetadataConstant.SystemMetadataKey.PEER_NAMESPACE,
MetadataContextHolder.get().getSystemMetadata( MetadataContextHolder.get().getSystemMetadata(

@ -42,7 +42,7 @@ public class MetadataFirstFeignInterceptor implements RequestInterceptor, Ordere
// get metadata of current thread // get metadata of current thread
MetadataContext metadataContext = MetadataContextHolder.get(); MetadataContext metadataContext = MetadataContextHolder.get();
// TODO 对端命名空间暂时与本地命名空间相同 // TODO The peer namespace is temporarily the same as the local namespace
metadataContext.putSystemMetadata( metadataContext.putSystemMetadata(
MetadataConstant.SystemMetadataKey.PEER_NAMESPACE, MetadataConstant.SystemMetadataKey.PEER_NAMESPACE,
MetadataContextHolder.get().getSystemMetadata( MetadataContextHolder.get().getSystemMetadata(

@ -68,9 +68,9 @@ public class Metadata2HeaderFeignInterceptorTest {
public void test1() throws JsonProcessingException { public void test1() throws JsonProcessingException {
String metadata = testFeign.test(); String metadata = testFeign.test();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
Assertions.assertThat(mapper.readTree(metadata)).isEqualTo(mapper.readTree( Assertions.assertThat(metadata).isEqualTo(
"{\"a\":\"11\",\"b\":\"22\",\"c\":\"33\"}{\"LOCAL_SERVICE\":\"test" "{\"a\":\"11\",\"b\":\"22\",\"c\":\"33\"}{\"LOCAL_SERVICE\":\"test"
+ "\",\"LOCAL_PATH\":\"/test\",\"LOCAL_NAMESPACE\":\"default\"}")); + "\",\"LOCAL_PATH\":\"/test\",\"LOCAL_NAMESPACE\":\"default\"}");
Assertions.assertThat(metadataLocalProperties.getContent().get("a")) Assertions.assertThat(metadataLocalProperties.getContent().get("a"))
.isEqualTo("1"); .isEqualTo("1");
Assertions.assertThat(metadataLocalProperties.getContent().get("b")) Assertions.assertThat(metadataLocalProperties.getContent().get("b"))

@ -23,6 +23,11 @@
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-polaris-context</artifactId> <artifactId>spring-cloud-tencent-polaris-context</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<!-- Spring Cloud Tencent dependencies end --> <!-- Spring Cloud Tencent dependencies end -->
<!-- Polaris dependencies start --> <!-- Polaris dependencies start -->

@ -70,7 +70,7 @@ public class PolarisFeignClientAutoConfiguration {
@Override @Override
public void modify(ConfigurationImpl configuration) { public void modify(ConfigurationImpl configuration) {
// 开启熔断配置 // Enable circuit breaker.
configuration.getConsumer().getCircuitBreaker().setEnable(true); configuration.getConsumer().getCircuitBreaker().setEnable(true);
} }

@ -30,6 +30,8 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
/** /**
* Test for {@link PolarisFeignClient}.
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a> * @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)

@ -25,6 +25,8 @@ import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
/** /**
* Test application.
*
* @author <a href="mailto:liaochuntao@live.com">liaochuntao</a> * @author <a href="mailto:liaochuntao@live.com">liaochuntao</a>
*/ */
@SpringBootApplication @SpringBootApplication

@ -8,8 +8,8 @@ feign:
enable: true enable: true
compression: compression:
request: request:
enabled: false #是否对请求进行GZIP压缩 enabled: false
mime-types: text/xml,application/xml,application/json #指定压缩的请求数据类型 mime-types: text/xml,application/xml,application/json
min-request-size: 2048 #超过该大小的请求会被压缩 min-request-size: 2048
response: response:
enabled: false #是否对响应进行GZIP压缩 enabled: false

@ -19,6 +19,7 @@ package com.tencent.cloud.polaris.discovery;
import com.tencent.cloud.polaris.PolarisProperties; import com.tencent.cloud.polaris.PolarisProperties;
import com.tencent.cloud.polaris.discovery.reactive.PolarisReactiveDiscoveryClientConfiguration; import com.tencent.cloud.polaris.discovery.reactive.PolarisReactiveDiscoveryClientConfiguration;
import com.tencent.cloud.polaris.extend.consul.ConsulContextProperties;
import com.tencent.polaris.api.core.ConsumerAPI; import com.tencent.polaris.api.core.ConsumerAPI;
import com.tencent.polaris.api.core.ProviderAPI; import com.tencent.polaris.api.core.ProviderAPI;
import com.tencent.polaris.api.exception.PolarisException; import com.tencent.polaris.api.exception.PolarisException;
@ -39,7 +40,8 @@ import org.springframework.context.annotation.Import;
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@ConditionalOnPolarisDiscoveryEnabled @ConditionalOnPolarisDiscoveryEnabled
@Import({ PolarisDiscoveryClientConfiguration.class, @Import({ PolarisDiscoveryClientConfiguration.class,
PolarisReactiveDiscoveryClientConfiguration.class }) PolarisReactiveDiscoveryClientConfiguration.class,
ConsulContextProperties.class })
public class PolarisDiscoveryAutoConfiguration { public class PolarisDiscoveryAutoConfiguration {
@Bean @Bean

@ -15,7 +15,7 @@
* specific language governing permissions and limitations under the License. * specific language governing permissions and limitations under the License.
*/ */
package com.tencent.cloud.polaris.context.extend.consul; package com.tencent.cloud.polaris.extend.consul;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;

@ -27,6 +27,8 @@ import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* Auto service registration of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
public class PolarisAutoServiceRegistration public class PolarisAutoServiceRegistration

@ -30,6 +30,8 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.Registration;
/** /**
* Registration object of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
public class PolarisRegistration implements Registration, ServiceInstance { public class PolarisRegistration implements Registration, ServiceInstance {

@ -45,6 +45,8 @@ import org.springframework.util.StringUtils;
import static org.springframework.util.ReflectionUtils.rethrowRuntimeException; import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
/** /**
* Service registry of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
public class PolarisServiceRegistry implements ServiceRegistry<Registration> { public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
@ -86,7 +88,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
log.warn("No service to register for polaris client..."); log.warn("No service to register for polaris client...");
return; return;
} }
// 注册实例 // Register instance.
InstanceRegisterRequest instanceRegisterRequest = new InstanceRegisterRequest(); InstanceRegisterRequest instanceRegisterRequest = new InstanceRegisterRequest();
instanceRegisterRequest.setNamespace(polarisProperties.getNamespace()); instanceRegisterRequest.setNamespace(polarisProperties.getNamespace());
instanceRegisterRequest.setService(registration.getServiceId()); instanceRegisterRequest.setService(registration.getServiceId());
@ -110,7 +112,7 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
if (null != heartbeatExecutor) { if (null != heartbeatExecutor) {
InstanceHeartbeatRequest heartbeatRequest = new InstanceHeartbeatRequest(); InstanceHeartbeatRequest heartbeatRequest = new InstanceHeartbeatRequest();
BeanUtils.copyProperties(instanceRegisterRequest, heartbeatRequest); BeanUtils.copyProperties(instanceRegisterRequest, heartbeatRequest);
// 注册成功后开始启动心跳线程 // Start the heartbeat thread after the registration is successful.
heartbeat(heartbeatRequest); heartbeat(heartbeatRequest);
} }
} }
@ -190,7 +192,11 @@ public class PolarisServiceRegistry implements ServiceRegistry<Registration> {
heartbeatExecutor.scheduleWithFixedDelay(() -> { heartbeatExecutor.scheduleWithFixedDelay(() -> {
try { try {
String healthCheckEndpoint = polarisProperties.getHealthCheckUrl(); String healthCheckEndpoint = polarisProperties.getHealthCheckUrl();
// 先判断是否配置了health-check-url如果配置了需要先进行服务实例健康检查如果健康检查通过则进行心跳上报如果不通过则不上报心跳 // First determine whether health-check-url is configured.
// If configured, the service instance health check needs to be executed
// first.
// If the health check passes, the heartbeat will be reported.
// If it does not pass, the heartbeat will not be reported.
if (Strings.isNotEmpty(healthCheckEndpoint)) { if (Strings.isNotEmpty(healthCheckEndpoint)) {
if (!healthCheckEndpoint.startsWith("/")) { if (!healthCheckEndpoint.startsWith("/")) {
healthCheckEndpoint = "/" + healthCheckEndpoint; healthCheckEndpoint = "/" + healthCheckEndpoint;

@ -35,6 +35,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* Autoconfiguration of service registry of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

@ -26,6 +26,8 @@ import org.springframework.cloud.netflix.ribbon.RibbonClients;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* Autoconfiguration of ribbon of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)

@ -27,6 +27,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* Configuration of server list.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
@Configuration @Configuration

@ -30,6 +30,8 @@ import com.tencent.polaris.api.pojo.ServiceInstances;
import com.tencent.polaris.api.rpc.InstancesResponse; import com.tencent.polaris.api.rpc.InstancesResponse;
/** /**
* Server list of Polaris.
*
* @author Haotian Zhang, Andrew Shan, Jie Cheng * @author Haotian Zhang, Andrew Shan, Jie Cheng
*/ */
public class PolarisServerList extends AbstractServerList<Server> { public class PolarisServerList extends AbstractServerList<Server> {

@ -40,13 +40,13 @@ public class PolarisPropertiesTest {
new InetUtils(new InetUtilsProperties())); new InetUtils(new InetUtilsProperties()));
try { try {
temp.setNamespace(NAMESPACE_TEST); temp.setNamespace(NAMESPACE_TEST);
temp.getNamespace(); assertThat(temp.getNamespace()).isEqualTo(NAMESPACE_TEST);
temp.setService(SERVICE_PROVIDER); temp.setService(SERVICE_PROVIDER);
temp.getService(); assertThat(temp.getService()).isEqualTo(SERVICE_PROVIDER);
temp.setToken("xxxxxx"); temp.setToken("xxxxxx");
temp.getToken(); assertThat(temp.getToken()).isEqualTo("xxxxxx");
temp.init(); temp.init();
assertThat(temp).isNotNull(); assertThat(temp).isNotNull();

@ -108,7 +108,7 @@ public class PolarisServerListTest {
*/ */
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void test2() throws Exception { public void test2() {
this.contextRunner.run(context -> { this.contextRunner.run(context -> {
// mock // mock
IClientConfig iClientConfig = mock(IClientConfig.class); IClientConfig iClientConfig = mock(IClientConfig.class);

@ -27,7 +27,7 @@
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-commons</artifactId> <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency> </dependency>
<!-- Spring Cloud Tencent dependencies end --> <!-- Spring Cloud Tencent dependencies end -->

@ -102,7 +102,8 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered {
} }
} }
catch (Throwable t) { catch (Throwable t) {
// 限流API调用出现异常不应该影响业务流程的调用 // An exception occurs in the rate limiting API call,
// which should not affect the call of the business process.
LOG.error("fail to invoke getQuota, service is " + localService, t); LOG.error("fail to invoke getQuota, service is " + localService, t);
} }

@ -90,7 +90,8 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter {
} }
} }
catch (Throwable t) { catch (Throwable t) {
// 限流API调用出现异常不应该影响业务流程的调用 // An exception occurs in the rate limiting API call,
// which should not affect the call of the business process.
LOG.error("fail to invoke getQuota, service is " + localService, t); LOG.error("fail to invoke getQuota, service is " + localService, t);
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
} }

@ -18,22 +18,27 @@
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-commons</artifactId> <artifactId>spring-cloud-tencent-commons</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-polaris-context</artifactId> <artifactId>spring-cloud-tencent-polaris-context</artifactId>
</dependency> </dependency>
<!-- Spring Cloud Tencent dependencies end -->
<!-- Polaris dependencies start --> <dependency>
<dependency> <groupId>com.tencent.cloud</groupId>
<groupId>com.tencent.polaris</groupId> <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
<artifactId>polaris-router-factory</artifactId> </dependency>
</dependency> <!-- Spring Cloud Tencent dependencies end -->
<dependency> <!-- Polaris dependencies start -->
<groupId>com.tencent.polaris</groupId> <dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>polaris-router-factory</artifactId>
</dependency>
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>polaris-test-common</artifactId> <artifactId>polaris-test-common</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

@ -33,6 +33,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* Configuration of ribbon client of Polaris.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@Configuration @Configuration

@ -20,7 +20,7 @@ package com.tencent.cloud.common.constant;
/** /**
* Constant for Context. * Constant for Context.
* *
* @author skyehtzhang * @author Haotian Zhang
*/ */
public final class ContextConstant { public final class ContextConstant {

@ -17,68 +17,16 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <groupId>com.tencent.cloud</groupId>
<groupId>com.tencent.cloud</groupId> <artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
</dependency> </dependency>
</dependencies>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-polaris-context</artifactId>
</dependency>
<!-- feign客户端依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<!-- 负载均衡依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!-- import spring boot dependencies management-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>

@ -21,7 +21,7 @@ import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
/** /**
* service b provider. * Circuit breaker example callee provider.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */

@ -20,7 +20,7 @@ package com.tencent.cloud.polaris.circuitbreaker.example;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* provider b fallback * Circuit breaker example callee fallback.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */

@ -19,28 +19,26 @@ package com.tencent.cloud.polaris.circuitbreaker.example;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* circuitbraker example. * Circuit breaker example caller application.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients @EnableFeignClients
public class ServiceA { public class ServiceA {
public static void main(String[] args) {
SpringApplication.run(ServiceA.class);
}
@Bean @Bean
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
public static void main(String[] args) {
SpringApplication.run(ServiceA.class);
}
} }

@ -17,15 +17,15 @@
package com.tencent.cloud.polaris.circuitbreaker.example; package com.tencent.cloud.polaris.circuitbreaker.example;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Service A Controller * Circuit breaker example caller controller.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@ -33,34 +33,26 @@ import org.springframework.web.client.RestTemplate;
@RequestMapping("/example/service/a") @RequestMapping("/example/service/a")
public class ServiceAController { public class ServiceAController {
private final ProviderB polarisServiceB; @Autowired
private ProviderB polarisServiceB;
private final RestTemplate restTemplate; @Autowired
private RestTemplate restTemplate;
public ServiceAController(ProviderB polarisServiceB, RestTemplate restTemplate) {
this.polarisServiceB = polarisServiceB;
this.restTemplate = restTemplate;
}
/**
*
* @return
*/
@GetMapping("/info")
public String info() {
return "hello world ! I'am a service";
}
/** /**
* B * Get info of Service B by Feign.
* @return B * @return info of Service B
*/ */
@GetMapping("/getBServiceInfo") @GetMapping("/getBServiceInfo")
public String getBServiceInfo() { public String getBServiceInfo() {
return polarisServiceB.info(); return polarisServiceB.info();
} }
@RequestMapping(value = "/testRest", method = RequestMethod.GET) /**
* Get info of Service B by RestTemplate.
* @return info of Service B
*/
@GetMapping("/testRest")
public String testRest() { public String testRest() {
ResponseEntity<String> entity = restTemplate.getForEntity( ResponseEntity<String> entity = restTemplate.getForEntity(
"http://polaris-circuitbreaker-example-b/example/service/b/info", "http://polaris-circuitbreaker-example-b/example/service/b/info",

@ -1,5 +1,4 @@
server: server:
session-timeout: 1800
port: 48080 port: 48080
spring: spring:
application: application:
@ -7,29 +6,21 @@ spring:
cloud: cloud:
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://127.0.0.1:8091
global:
api:
timeout: 5s
feign: feign:
hystrix: hystrix:
enabled: true #在Feign中开启Hystrix enabled: true
compression: compression:
request: request:
enabled: false #是否对请求进行GZIP压缩 enabled: false
mime-types: text/xml,application/xml,application/json #指定压缩的请求数据类型 mime-types: text/xml,application/xml,application/json
min-request-size: 2048 #超过该大小的请求会被压缩 min-request-size: 2048
response: response:
enabled: false #是否对响应进行GZIP压缩 enabled: false
ribbon: ribbon:
polaris: polaris:
enabled: true enabled: true
# 同一实例最大重试次数,不包括首次调用
MaxAutoRetries: 1 MaxAutoRetries: 1
# 重试其他实例的最大重试次数不包括首次所选的server
MaxAutoRetriesNextServer: 2 MaxAutoRetriesNextServer: 2
# 是否所有操作都进行重试
OkToRetryOnAllOperations: false OkToRetryOnAllOperations: false
ConnectionTimeout: 1000 ConnectionTimeout: 1000
ReadTimeout: 1000 ReadTimeout: 1000

@ -1,284 +1,14 @@
#描述:全局配置项
global:
#描述系统相关配置
system:
#描述:SDK运行模式
#类型:enum
#范围:0直连模式SDK直接对接server; 1代理模式SDK只对接agent, 通过agent进行server的对接
#默认值:0
mode: 0
#服务发现集群
discoverCluster:
namespace: Polaris
service: polaris.discover
#可选:服务刷新间隔
refreshInterval: 10m
#健康检查集群
healthCheckCluster:
namespace: Polaris
service: polaris.healthcheck
#可选:服务刷新间隔
refreshInterval: 10m
#监控上报集群
monitorCluster:
namespace: Polaris
service: polaris.monitor
#可选:服务刷新间隔
refreshInterval: 10m
api:
#描述:api超时时间
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:1s
timeout: 5s
#描述:上报间隔
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:10m
reportInterval: 10m
#描述:API因为网络原因调用失败后的重试次数
#类型:int
#范围:[0:...]
#默认值:5
maxRetryTimes: 5
#描述:重试间隔
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1s:...]
#默认值:1s
retryInterval: 1s
#描述:对接polaris server的相关配置
serverConnector:
#描述:访问server的连接协议SDK会根据协议名称会加载对应的插件
#类型:string
#范围:已注册的连接器插件名
#默认值:grpc
protocol: grpc
#描述:发起连接后的连接超时时间
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:200ms
connectTimeout: 500ms
#描述:远程请求超时时间
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:1s
messageTimeout: 5s
#描述:连接空闲时间长连接模式下当连接空闲超过一定时间后SDK会主动释放连接
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:1s
connectionIdleTimeout: 1s
#描述:首次请求的任务队列长度当用户发起首次服务访问请求时SDK会对任务进行队列调度并连接server当积压的任务数超过队列长度后SDK会直接拒绝首次请求的发起。
#类型:int
#范围:[0:...]
#默认值:1000
requestQueueSize: 1000
#描述:server节点的切换周期为了使得server的压力能够均衡SDK会定期针对最新的节点列表进行重新计算自己当前应该连接的节点假如和当前不一致则进行切换
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1m:...]
#默认值:10m
serverSwitchInterval: 10m
plugin:
grpc:
#描述:GRPC客户端单次最大链路接收报文
#类型:int
#范围:(0:524288000]
maxCallRecvMsgSize: 52428800
#统计上报设置
statReporter:
#描述是否将统计信息上报至monitor
#类型bool
#默认值true
enable: true
#描述:启用的统计上报插件类型
#类型list
#范围:已经注册的统计上报插件的名字
#默认值stat2Monitor(将信息上报至monitor服务)
chain:
- stat2Monitor
- serviceCache
#描述:统计上报插件配置
plugin:
stat2Monitor:
#描述:每次上报多长一段时间的统计信息
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1m:...]
metricsReportWindow: 1m
#描述:将一段时间内的统计信息分为多少个基本单元收集
#类型:int
#范围:[1:...]
#默认值:12
metricsNumBuckets: 12
serviceCache:
#描述:上报缓存信息的周期
reportInterval: 3m
#描述:主调端配置
consumer: consumer:
#描述:本地缓存相关配置
localCache:
#描述:缓存类型
#类型:string
#范围:已注册的本地缓存插件名
#默认值:inmemory基于本机内存的缓存策略
type: inmemory
#描述:服务过期淘汰时间
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1m:...]
#默认值:24h
serviceExpireTime: 24h
#描述:服务定期刷新周期
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1s:...]
#默认值:2s
serviceRefreshInterval: 2s
#描述:服务缓存持久化目录SDK在实例数据更新后按照服务维度将数据持久化到磁盘
#类型:string
#格式:本机磁盘目录路径,支持$HOME变量
#默认值:$HOME/polaris/backup
persistDir: ./polaris/backup
#描述:缓存写盘失败的最大重试次数
#类型:int
#范围:[1:...]
#默认值:5
persistMaxWriteRetry: 5
#描述:缓存从磁盘读取失败的最大重试次数
#类型:int
#范围:[1:...]
#默认值:1
persistMaxReadRetry: 1
#描述:缓存读写磁盘的重试间隔
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1ms:...]
#默认值:1s
persistRetryInterval: 1s
#描述:服务路由相关配置
serviceRouter:
# 服务路由链
chain:
# 基于主调和被调服务规则的路由策略(默认的路由策略)
- ruleBasedRouter
# 就近路由策略
- nearbyBasedRouter
#描述:服务路由插件的配置
plugin:
nearbyBasedRouter:
#描述:就近路由的最小匹配级别
#类型:string
#范围:region(大区)、zone(区域)、campus(园区)
#默认值:zone
matchLevel: zone
ruleBasedRouter: { }
recoverRouter:
#至少应该返回多少比率的实例如果不填默认0%,即全死全活
percentOfMinInstances: 0
#是否开启全死全活,默认开启
enableRecoverAll: true
#描述:负载均衡相关配置
loadbalancer:
#描述:负载均衡类型
#范围:已注册的负载均衡插件名
#默认值:权重随机负载均衡
type: weightedRandom
plugin:
#描述:虚拟节点的数量
#类型:int
#默认值:500
ringHash:
vnodeCount: 500
#描述:节点熔断相关配置
circuitBreaker: circuitBreaker:
#描述:是否启用节点熔断功能
#类型:bool
#默认值:true
enable: true
#描述:实例定时熔断检测周期
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[100ms:...]
#默认值:30s
checkPeriod: 100ms checkPeriod: 100ms
#描述:熔断器半开后最大允许的请求数
#类型:int
#范围:[3:...]
#默认值:10
requestCountAfterHalfOpen: 10
#描述:熔断器打开后,多久后转换为半开状态
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1s:...]
#默认值:30s
sleepWindow: 60s
#描述:熔断器半开到关闭所必须的最少成功请求数
#类型:int
#范围:[1:requestCountAfterHalfOpen]
#默认值:8
successCountAfterHalfOpen: 8
#描述:熔断器半开到关闭的统计周期
#类型:string
#范围:[10s:...]
#默认值:60s
recoverWindow: 60s
#描述:熔断器半开到关闭的统计滑桶数
#类型:int
#范围:[1:...]
#默认值:10
recoverNumBuckets: 10
#描述:熔断策略SDK会根据策略名称加载对应的熔断器插件
#类型:list
#范围:已注册的熔断器插件名
#默认值基于周期连续错误数熔断errorCount、以及基于周期错误率的熔断策略errorRate
chain: chain:
- errorCount - errorCount
- errorRate - errorRate
#描述:熔断插件配置
plugin: plugin:
#描述:基于周期连续错误数熔断策略配置
errorCount: errorCount:
#描述:触发连续错误熔断的阈值
#类型:int
#范围:[1:...]
#默认值:10
continuousErrorThreshold: 1 continuousErrorThreshold: 1
#描述:连续错误数的最小统计单元数量
#类型:int
#范围:[1:...]
#默认值:10
metricNumBuckets: 1 metricNumBuckets: 1
#描述:连续失败的统计周期
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[10ms:...]
#默认值:1m
metricStatTimeWindow: 100ms
#描述:基于周期错误率的熔断策略配置
errorRate: errorRate:
#描述:触发错误率熔断的阈值百分比 errorRateThreshold: 100
errorRateThreshold: 50
#描述:错误率熔断的最小统计单元数量
#类型:int
#范围:[1:...]
#默认值:5
metricNumBuckets: 5
#描述:错误率熔断的统计周期
#类型:string
#格式:^\d+(ms|s|m|h)$
#范围:[1s:...]
#默认值:1m
metricStatTimeWindow: 1s metricStatTimeWindow: 1s
#描述:触发错误率熔断的最低请求阈值
#类型:int
#范围:(0:...]
#默认值:10
requestVolumeThreshold: 1 requestVolumeThreshold: 1

@ -17,66 +17,11 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
</dependencies>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-tencent-polaris-context</artifactId>
</dependency>
<!-- feign客户端依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
</dependency>
<!-- 负载均衡依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<!-- import spring boot dependencies management-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build> <build>
<plugins> <plugins>

@ -1,39 +0,0 @@
/*
* 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.example;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* service a provider.
*
* @author Haotian Zhang
*/
@FeignClient(name = "polaris-circuitbreaker-example-a",
fallback = ProviderAFallback.class)
public interface ProviderA {
/**
* Get info of service A.
* @return info of service A
*/
@GetMapping("/example/service/a/info")
String info();
}

@ -1,35 +0,0 @@
/*
* 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.example;
import org.springframework.stereotype.Component;
/**
* provider a fallback
*
* @author Haotian Zhang
*/
@Component
public class ProviderAFallback implements ProviderA {
@Override
public String info() {
return "trigger the refuse for service a";
}
}

@ -19,28 +19,17 @@ package com.tencent.cloud.polaris.circuitbreaker.example;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/** /**
* circuitbraker example. * Circuit breaker example callee application.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class ServiceB { public class ServiceB {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ServiceB.class); SpringApplication.run(ServiceB.class);
} }
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
} }

@ -17,15 +17,13 @@
package com.tencent.cloud.polaris.circuitbreaker.example; package com.tencent.cloud.polaris.circuitbreaker.example;
import org.springframework.http.ResponseEntity; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
/** /**
* Service B Controller * Service B Controller.
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@ -33,40 +31,21 @@ import org.springframework.web.client.RestTemplate;
@RequestMapping("/example/service/b") @RequestMapping("/example/service/b")
public class ServiceBController { public class ServiceBController {
private final ProviderA polarisServiceA; @Value("${is-throw-runtime-exception:#{true}}")
private boolean isThrowRuntimeException;
private final RestTemplate restTemplate;
public ServiceBController(ProviderA polarisServiceA, RestTemplate restTemplate) {
this.polarisServiceA = polarisServiceA;
this.restTemplate = restTemplate;
}
/** /**
* * Get service information.
* @return * @return service information
*/ */
@GetMapping("/info") @GetMapping("/info")
public String info() { public String info() {
// return "hello world ! I'am a service"; if (isThrowRuntimeException) {
throw new RuntimeException("failed for call my service"); throw new RuntimeException("failed for call my service");
} }
else {
/** return "hello world ! I'm a service B";
* B }
* @return B
*/
@GetMapping("/getAServiceInfo")
public String getAServiceInfo() {
return polarisServiceA.info();
}
@RequestMapping(value = "/testRest", method = RequestMethod.GET)
public String testRest() {
ResponseEntity<String> entity = restTemplate.getForEntity(
"http://polaris-circuitbreaker-example-a/example/service/b/info",
String.class);
return entity.getBody();
} }
} }

@ -1,5 +1,4 @@
server: server:
session-timeout: 1800
port: 48081 port: 48081
spring: spring:
application: application:
@ -7,34 +6,4 @@ spring:
cloud: cloud:
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://127.0.0.1:8091
global: is-throw-runtime-exception: false
api:
timeout: 5s
feign:
hystrix:
enabled: true #在Feign中开启Hystrix
compression:
request:
enabled: false #是否对请求进行GZIP压缩
mime-types: text/xml,application/xml,application/json #指定压缩的请求数据类型
min-request-size: 2048 #超过该大小的请求会被压缩
response:
enabled: false #是否对响应进行GZIP压缩
ribbon:
polaris:
enabled: true
# 同一实例最大重试次数,不包括首次调用
MaxAutoRetries: 1
# 重试其他实例的最大重试次数不包括首次所选的server
MaxAutoRetriesNextServer: 2
# 是否所有操作都进行重试
OkToRetryOnAllOperations: false
ConnectionTimeout: 1000
ReadTimeout: 1000
eager-load:
enabled: on
serivceB:
url: http://localhost:48081

@ -1,64 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>polaris-circuitbreaker-example</artifactId> <artifactId>polaris-circuitbreaker-example</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>
<module>polaris-circuitbreaker-example-a</module> <module>polaris-circuitbreaker-example-a</module>
<module>polaris-circuitbreaker-example-b</module> <module>polaris-circuitbreaker-example-b</module>
</modules> </modules>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
<artifactId>spring-boot-starter-web</artifactId> <groupId>com.tencent.cloud</groupId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
<scope>test</scope> </dependency>
</dependency>
<dependency>
<!-- 系统服务监控依赖 --> <groupId>org.springframework.cloud</groupId>
<dependency> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<groupId>org.springframework.boot</groupId> </dependency>
<artifactId>spring-boot-starter-actuator</artifactId> </dependencies>
</dependency>
<!-- feign客户端依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- 熔断依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<!-- 负载均衡依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies>
</project> </project>

@ -14,21 +14,21 @@
<name>Polaris Discovery Callee Service</name> <name>Polaris Discovery Callee Service</name>
<dependencies> <dependencies>
<dependency> <dependency>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>--> <!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>--> <!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>--> <!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>--> <!-- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>-->
<!-- </dependency>--> <!-- </dependency>-->
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -17,27 +17,23 @@
package com.tencent.cloud.polaris.discovery.service.callee; package com.tencent.cloud.polaris.discovery.service.callee;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* Discovery callee controller.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@RestController @RestController
@RequestMapping("/discovery/service/callee") @RequestMapping("/discovery/service/callee")
public class DiscoveryCalleeController { public class DiscoveryCalleeController {
private static Logger logger = LoggerFactory
.getLogger(DiscoveryCalleeController.class);
/** /**
* * Get information of callee.
* @return * @return information of callee
*/ */
@GetMapping("/info") @GetMapping("/info")
public String info() { public String info() {
@ -45,10 +41,10 @@ public class DiscoveryCalleeController {
} }
/** /**
* * Get sum of two value.
* @param value1 1 * @param value1 value 1
* @param value2 2 * @param value2 value 2
* @return * @return sum
*/ */
@GetMapping("/sum") @GetMapping("/sum")
public int sum(@RequestParam int value1, @RequestParam int value2) { public int sum(@RequestParam int value1, @RequestParam int value2) {

@ -19,13 +19,13 @@ package com.tencent.cloud.polaris.discovery.service.callee;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController;
/** /**
* Discovery callee application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication
@RestController
public class DiscoveryCalleeService { public class DiscoveryCalleeService {
public static void main(String[] args) { public static void main(String[] args) {

@ -1,5 +1,4 @@
server: server:
session-timeout: 1800
port: 48084 port: 48084
spring: spring:
application: application:

@ -1,15 +0,0 @@
log4j.rootLogger=DEBUG,console,FILE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.threshold=INFO
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.Append=true
log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
log4j.appender.FILE.Threshold=INFO
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE.MaxFileSize=10MB

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--按天生成日志-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
</Pattern>
</layout>
</appender>
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</root>
</configuration>

@ -1,6 +1,10 @@
global: #global:
system: # system:
discoverCluster: # discoverCluster:
sameAsBuiltin: true # sameAsBuiltin: false
healthCheckCluster: # namespace: Polaris
sameAsBuiltin: true # service: polaris.discover
# healthCheckCluster:
# sameAsBuiltin: false
# namespace: Polaris
# service: polaris.healthcheck

@ -19,9 +19,9 @@
<dependencies> <dependencies>
<dependency> <dependency>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <groupId>com.tencent.cloud</groupId>
<groupId>com.tencent.cloud</groupId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>--> <!-- <groupId>org.springframework.cloud</groupId>-->

@ -22,17 +22,19 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
/** /**
* Discovery callee feign client.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@FeignClient(value = "DiscoveryCalleeService", @FeignClient(value = "DiscoveryCalleeService",
fallback = DiscoveryCalleeServiceCallback.class) fallback = DiscoveryCalleeServiceFallback.class)
public interface DiscoveryCalleeService { public interface DiscoveryCalleeService {
/** /**
* * Get sum of two value.
* @param value1 1 * @param value1 value 1
* @param value2 2 * @param value2 value 2
* @return * @return sum
*/ */
@GetMapping("/discovery/service/callee/sum") @GetMapping("/discovery/service/callee/sum")
int sum(@RequestParam("value1") int value1, @RequestParam("value2") int value2); int sum(@RequestParam("value1") int value1, @RequestParam("value2") int value2);

@ -20,10 +20,12 @@ package com.tencent.cloud.polaris.discovery.service.caller;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* Discovery callee feign client fallback.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@Component @Component
public class DiscoveryCalleeServiceCallback implements DiscoveryCalleeService { public class DiscoveryCalleeServiceFallback implements DiscoveryCalleeService {
@Override @Override
public int sum(int value1, int value2) { public int sum(int value1, int value2) {

@ -25,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Discovery caller controller.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@RestController @RestController
@ -38,10 +40,10 @@ public class DiscoveryCallerController {
private DiscoveryCalleeService discoveryCalleeService; private DiscoveryCalleeService discoveryCalleeService;
/** /**
* * Get sum of two value.
* @param value1 1 * @param value1 value 1
* @param value2 2 * @param value2 value 2
* @return * @return sum
*/ */
@GetMapping("/feign") @GetMapping("/feign")
public int feign(@RequestParam int value1, @RequestParam int value2) { public int feign(@RequestParam int value1, @RequestParam int value2) {
@ -49,8 +51,8 @@ public class DiscoveryCallerController {
} }
/** /**
* * Get information of callee.
* @return * @return information of callee
*/ */
@GetMapping("/rest") @GetMapping("/rest")
public String rest() { public String rest() {
@ -60,8 +62,8 @@ public class DiscoveryCallerController {
} }
/** /**
* health check * health check.
* @return * @return health check info
*/ */
@GetMapping("/healthCheck") @GetMapping("/healthCheck")
public String healthCheck() { public String healthCheck() {

@ -26,6 +26,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Discovery caller application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication

@ -1,15 +0,0 @@
log4j.rootLogger=DEBUG,console,FILE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.threshold=INFO
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.Append=true
log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
log4j.appender.FILE.Threshold=INFO
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE.MaxFileSize=10MB

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--按天生成日志-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} -%msg%n
</Pattern>
</layout>
</appender>
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</root>
</configuration>

@ -1,65 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>polaris-discovery-example</artifactId> <artifactId>polaris-discovery-example</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Spring Cloud Starter Tencent Polaris Discovery Example</name> <name>Spring Cloud Starter Tencent Polaris Discovery Example</name>
<modules> <modules>
<module>discovery-callee-service</module> <module>discovery-callee-service</module>
<module>discovery-caller-service</module> <module>discovery-caller-service</module>
</modules> </modules>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 系统服务监控依赖 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<!-- feign客户端依赖 -->
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<!-- 熔断依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<!-- 负载均衡依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -21,6 +21,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
/** /**
* Gateway callee application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication

@ -29,6 +29,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* Gateway callee controller.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@RestController @RestController
@ -38,8 +40,8 @@ public class GatewayCalleeController {
private static Logger logger = LoggerFactory.getLogger(GatewayCalleeController.class); private static Logger logger = LoggerFactory.getLogger(GatewayCalleeController.class);
/** /**
* Get info string * Get information of callee.
* @return * @return information of callee
*/ */
@RequestMapping("/info") @RequestMapping("/info")
public String info() { public String info() {
@ -47,7 +49,7 @@ public class GatewayCalleeController {
} }
/** /**
* Get metadata in HTTP header * Get metadata in HTTP header.
*/ */
@RequestMapping("/echo") @RequestMapping("/echo")
public String echoHeader( public String echoHeader(

@ -21,6 +21,8 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
/** /**
* SCG application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication

@ -25,14 +25,14 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId> <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

@ -22,6 +22,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy; import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
/** /**
* Zuul application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>spring-cloud-tencent-examples</artifactId> <artifactId>spring-cloud-tencent-examples</artifactId>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<version>${revision}</version> <version>${revision}</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>polaris-gateway-example</artifactId> <artifactId>polaris-gateway-example</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Spring Cloud Starter Tencent Polaris Gateway Example</name> <name>Spring Cloud Starter Tencent Polaris Gateway Example</name>
@ -20,38 +20,6 @@
<module>gateway-callee-service</module> <module>gateway-callee-service</module>
</modules> </modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- feign客户端依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- 熔断依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<!-- 负载均衡依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<artifactId>polaris-ratelimit-example</artifactId> <artifactId>polaris-ratelimit-example</artifactId>
@ -19,14 +19,16 @@
</dependency> </dependency>
<dependency> <dependency>
<artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId> <groupId>com.tencent.cloud</groupId>
<groupId>com.tencent.cloud</groupId> <artifactId>spring-cloud-starter-tencent-polaris-discovery</artifactId>
</dependency> </dependency>
<dependency>
<dependency>
<groupId>com.tencent.cloud</groupId> <groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-polaris-ratelimit</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-ratelimit</artifactId>
</dependency> </dependency>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId> <artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency> </dependency>

@ -30,6 +30,8 @@ import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Rate limit controller.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@RestController @RestController
@ -45,8 +47,8 @@ public class BusinessController {
private String appName; private String appName;
/** /**
* * Get information.
* @return * @return information
*/ */
@GetMapping("/info") @GetMapping("/info")
public String info() { public String info() {
@ -54,7 +56,7 @@ public class BusinessController {
} }
@GetMapping("/invoke") @GetMapping("/invoke")
public String invokeInfo() throws Exception { public String invokeInfo() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
try { try {

@ -24,6 +24,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
/** /**
* Rate limit application.
*
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication

@ -1,5 +1,4 @@
server: server:
session-timeout: 1800
port: 48081 port: 48081
spring: spring:
application: application:

@ -1,15 +0,0 @@
log4j.rootLogger=DEBUG,console,FILE
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.threshold=INFO
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.Append=true
log4j.appender.FILE.File=applog/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
log4j.appender.FILE.Threshold=INFO
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
log4j.appender.FILE.MaxFileSize=10MB

@ -52,19 +52,16 @@
<artifactId>connector-composite</artifactId> <artifactId>connector-composite</artifactId>
</dependency> </dependency>
<!--依赖resCache插件-->
<dependency> <dependency>
<groupId>com.tencent.polaris</groupId> <groupId>com.tencent.polaris</groupId>
<artifactId>registry-memory</artifactId> <artifactId>registry-memory</artifactId>
</dependency> </dependency>
<!--依赖flowCache插件-->
<dependency> <dependency>
<groupId>com.tencent.polaris</groupId> <groupId>com.tencent.polaris</groupId>
<artifactId>flow-cache-expired</artifactId> <artifactId>flow-cache-expired</artifactId>
</dependency> </dependency>
<!--依赖router插件-->
<dependency> <dependency>
<groupId>com.tencent.polaris</groupId> <groupId>com.tencent.polaris</groupId>
<artifactId>router-isolated</artifactId> <artifactId>router-isolated</artifactId>
@ -90,7 +87,6 @@
<artifactId>router-metadata</artifactId> <artifactId>router-metadata</artifactId>
</dependency> </dependency>
<!--依赖负载均衡插件-->
<dependency> <dependency>
<groupId>com.tencent.polaris</groupId> <groupId>com.tencent.polaris</groupId>
<artifactId>loadbalancer-random</artifactId> <artifactId>loadbalancer-random</artifactId>

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.tencent.cloud.common.constant.ContextConstant.ModifierOrder; import com.tencent.cloud.common.constant.ContextConstant.ModifierOrder;
import com.tencent.cloud.polaris.context.extend.consul.ConsulContextProperties;
import com.tencent.polaris.api.exception.PolarisException; import com.tencent.polaris.api.exception.PolarisException;
import com.tencent.polaris.client.api.SDKContext; import com.tencent.polaris.client.api.SDKContext;
import com.tencent.polaris.factory.config.ConfigurationImpl; import com.tencent.polaris.factory.config.ConfigurationImpl;
@ -38,8 +37,7 @@ import org.springframework.context.annotation.Bean;
* *
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@EnableConfigurationProperties({ PolarisContextProperties.class, @EnableConfigurationProperties(PolarisContextProperties.class)
ConsulContextProperties.class })
public class PolarisContextConfiguration { public class PolarisContextConfiguration {
private static final String ADDRESS_SEPARATOR = ","; private static final String ADDRESS_SEPARATOR = ",";

@ -10,9 +10,9 @@
{ {
"name": "spring.cloud.polaris.address", "name": "spring.cloud.polaris.address",
"type": "java.lang.String", "type": "java.lang.String",
"description": "polaris server 地址", "description": "polaris server address list that can be separated by \",\"",
"sourceType": "com.tencent.cloud.polaris.context.PolarisContextProperties" "sourceType": "com.tencent.cloud.polaris.context.PolarisContextProperties"
} }
], ],
"hints": [] "hints": []
} }

@ -1 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.tencent.cloud.polaris.context.PolarisContextConfiguration org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.tencent.cloud.polaris.context.PolarisContextConfiguration

Loading…
Cancel
Save