docs:optimize example (#386)

pull/388/head
Haotian Zhang 2 years ago committed by GitHub
parent 71015705d8
commit 3fa75f0b4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,3 +28,4 @@
- [Feature: support actuator for sct core components](https://github.com/Tencent/spring-cloud-tencent/pull/370)
- [docs: Fix javadoc <br /> error](https://github.com/Tencent/spring-cloud-tencent/pull/375)
- [docs: Update Readme.md](https://github.com/Tencent/spring-cloud-tencent/pull/381)
- [docs:optimize example](https://github.com/Tencent/spring-cloud-tencent/pull/386)

@ -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";
}
}
}

@ -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

Loading…
Cancel
Save