docs:optimize example (#385)

pull/394/head
Haotian Zhang 2 years ago committed by GitHub
parent e5f7a75e09
commit d10752a70d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,3 +36,4 @@
- [docs: Fix javadoc <br /> error](https://github.com/Tencent/spring-cloud-tencent/pull/371) - [docs: Fix javadoc <br /> error](https://github.com/Tencent/spring-cloud-tencent/pull/371)
- [UT: add Polaris LoadBalancer unit test](https://github.com/Tencent/spring-cloud-tencent/pull/373) - [UT: add Polaris LoadBalancer unit test](https://github.com/Tencent/spring-cloud-tencent/pull/373)
- [docs:update docs](https://github.com/Tencent/spring-cloud-tencent/pull/378) - [docs:update docs](https://github.com/Tencent/spring-cloud-tencent/pull/378)
- [docs:optimize example](https://github.com/Tencent/spring-cloud-tencent/pull/385)

@ -35,7 +35,7 @@ import org.springframework.web.client.RestTemplate;
public class ServiceA { public class ServiceA {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ServiceA.class); SpringApplication.run(ServiceA.class, args);
} }
@Bean @Bean
@ -43,5 +43,4 @@ public class ServiceA {
public RestTemplate restTemplate() { public RestTemplate restTemplate() {
return new RestTemplate(); return new RestTemplate();
} }
} }

@ -64,5 +64,4 @@ public class ServiceAController {
String.class); String.class);
return entity.getBody(); return entity.getBody();
} }
} }

@ -29,7 +29,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
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, args);
} }
} }

@ -18,7 +18,6 @@
package com.tencent.cloud.polaris.circuitbreaker.example; package com.tencent.cloud.polaris.circuitbreaker.example;
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.RestController; import org.springframework.web.bind.annotation.RestController;
@ -32,21 +31,12 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/example/service/b") @RequestMapping("/example/service/b")
public class ServiceBController { public class ServiceBController {
@Value("${is-throw-runtime-exception:#{false}}")
private boolean isThrowRuntimeException;
/** /**
* Get service information. * Get service information.
* @return service information * @return service information
*/ */
@GetMapping("/info") @GetMapping("/info")
public String info() { public String info() {
if (isThrowRuntimeException) { return "hello world ! I'm a service B1";
throw new RuntimeException("failed for call my service");
}
else {
return "hello world ! I'm a service B1";
}
} }
} }

@ -8,4 +8,3 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
is-throw-runtime-exception: false

@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class ServiceB2 { public class ServiceB2 {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ServiceB2.class); SpringApplication.run(ServiceB2.class, args);
} }
} }

@ -18,9 +18,10 @@
package com.tencent.cloud.polaris.ciruitbreaker.example; package com.tencent.cloud.polaris.ciruitbreaker.example;
import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus;
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.ResponseStatus;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
@ -32,21 +33,13 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/example/service/b") @RequestMapping("/example/service/b")
public class ServiceBController { public class ServiceBController {
@Value("${is-throw-runtime-exception:#{false}}")
private boolean isThrowRuntimeException;
/** /**
* Get service information. * Get service information.
* @return service information * @return service information
*/ */
@GetMapping("/info") @GetMapping("/info")
@ResponseStatus(value = HttpStatus.BAD_GATEWAY, reason = "failed for call my service")
public String info() { public String info() {
if (isThrowRuntimeException) { return "failed for call service B2";
throw new RuntimeException("failed for call my service");
}
else {
return "hello world ! I'm a service B2";
}
} }
} }

@ -8,4 +8,3 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
is-throw-runtime-exception: true

@ -17,4 +17,4 @@ management:
web: web:
exposure: exposure:
include: include:
- polaris-config - polaris-config

Loading…
Cancel
Save