docs:optimize example (#387)

pull/390/head
Haotian Zhang 3 years ago committed by GitHub
parent 3b0a244fca
commit 55c1d29225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -25,3 +25,4 @@
- [Refator JacksonUtils and JacksonUtilsTest](https://github.com/Tencent/spring-cloud-tencent/pull/367)
- [Feature: support actuator for sct core components](https://github.com/Tencent/spring-cloud-tencent/pull/369)
- [docs: Fix javadoc <br /> error](https://github.com/Tencent/spring-cloud-tencent/pull/376)
- [docs:optimize example](https://github.com/Tencent/spring-cloud-tencent/pull/387)

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

@ -63,5 +63,4 @@ public class ServiceAController {
.getForEntity("http://polaris-circuitbreaker-example-b/example/service/b/info", String.class);
return entity.getBody();
}
}

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

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

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

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

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

Loading…
Cancel
Save