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