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