diff --git a/service/cloud-demo1/src/main/java/cn/bunny/controller/PropertiesController.java b/service/cloud-demo1/src/main/java/cn/bunny/controller/PropertiesController.java index 1e25b73..dd364a4 100644 --- a/service/cloud-demo1/src/main/java/cn/bunny/controller/PropertiesController.java +++ b/service/cloud-demo1/src/main/java/cn/bunny/controller/PropertiesController.java @@ -2,6 +2,7 @@ package cn.bunny.controller; import cn.bunny.feign.CloudFeignClient; import cn.bunny.properties.OrderProperties; +import com.alibaba.csp.sentinel.annotation.SentinelResource; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.beans.factory.annotation.Autowired; @@ -24,15 +25,24 @@ public class PropertiesController { private CloudFeignClient cloudFeignClient; @GetMapping("config") + @SentinelResource(value = "getConfig", fallback = "getConfigFallBack") @Operation(summary = "获取云端配置属性", description = "获取云端配置属性") public String getConfig() { return "timeout:" + orderProperties.getTimeout() + ";autoConfirm:" + orderProperties.getConfirm() + ";dbUrl:" + orderProperties.getDbUrl(); } + /** + * 当获取速度过快时会走这个 + */ + public String getConfigFallBack() { + return "获取云端配置属性,操作过快。。。"; + } + @Operation(summary = "远程调用拦截token", description = "远程调用拦截token") @GetMapping("product") - String getProduct(@RequestParam("id") Long id) { + public String getProduct(@RequestParam("id") Long id) { // TokenRequestInterceptor 会将内容放到请求头中之后在另一个微服务中查看请求头即可 return cloudFeignClient.getProduct(id); } + }