feat: save code

pull/12/head
chuntaojun 4 years ago
parent fa5d0eefb8
commit cd91b69f80

@ -44,6 +44,11 @@
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- 熔断超时后,重试机制依赖--> <!-- 熔断超时后,重试机制依赖-->
<dependency> <dependency>
<groupId>org.springframework.retry</groupId> <groupId>org.springframework.retry</groupId>

@ -13,11 +13,24 @@
<artifactId>ratelimit-callee-service</artifactId> <artifactId>ratelimit-callee-service</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.6</version>
<scope>compile</scope>
</dependency>
<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.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<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>
@ -30,5 +43,9 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId> <artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -20,6 +20,8 @@ package com.tencent.cloud.ratelimit.example.service.callee;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Configuration;
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;
@ -43,6 +45,12 @@ public class BusinessController {
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String appName; private String appName;
@Configuration
@LoadBalancerClient(value = "service-provider")
class RateLimitCalleeConfiguration {
}
/** /**
* *

@ -20,6 +20,7 @@ package com.tencent.cloud.ratelimit.example.service.callee;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -28,7 +29,7 @@ import org.springframework.web.client.RestTemplate;
* @author Haotian Zhang * @author Haotian Zhang
*/ */
@SpringBootApplication @SpringBootApplication
@EnableAutoConfiguration @EnableDiscoveryClient
public class RateLimitCalleeService { public class RateLimitCalleeService {
@Bean @Bean

@ -1,11 +1,12 @@
server: server:
session-timeout: 1800
port: 48081 port: 48081
spring: spring:
application: application:
name: RateLimitCalleeService name: RateLimitCalleeService
cloud: cloud:
loadbalancer:
configurations: default
polaris: polaris:
address: grpc://127.0.0.1:8091 address: grpc://9.135.224.139:8091
discovery: discovery:
namespace: Test namespace: default

@ -20,7 +20,6 @@ package com.tencent.cloud.polaris.circuitbreaker.feign;
import feign.Client; import feign.Client;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties;
import org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient;

@ -31,6 +31,12 @@
</dependency> </dependency>
<!-- Spring Cloud Tencent dependencies end --> <!-- Spring Cloud Tencent dependencies end -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
<optional>true</optional>
</dependency>
<!-- Polaris dependencies start --> <!-- Polaris dependencies start -->
<dependency> <dependency>
<groupId>com.tencent.polaris</groupId> <groupId>com.tencent.polaris</groupId>

@ -34,6 +34,7 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId> <artifactId>spring-cloud-loadbalancer</artifactId>
<optional>true</optional>
</dependency> </dependency>
<!-- Polaris dependencies start --> <!-- Polaris dependencies start -->

Loading…
Cancel
Save