diff --git a/README.md b/README.md index 57372f4..32811be 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ novel 是一套基于时下**最新** Java 技术栈 Spring Boot 3 + Vue 3 开 | MySQL | 8.0 | 数据库服务 | https://www.mysql.com | [进入](https://docs.oracle.com/en-us/iaas/mysql-database/doc/getting-started.html) | | Elasticsearch | 8.2.0 | 搜索引擎服务 | https://www.elastic.co | [进入](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) | | RabbitMQ | 3.10.2 | 开源消息中间件 | https://www.rabbitmq.com | [进入](https://www.rabbitmq.com/tutorials/tutorial-one-java.html) | -| XXL-JOB | 2.3.1 | 分布式任务调度平台 | https://www.xuxueli.com/xxl-job | [进入](https://www.xuxueli.com/xxl-job) | +| XXL-JOB | 2.3.1 | 分布式任务调度平台 | https://www.xuxueli.com/xxl-job | [进入](https://www.xuxueli.com/xxl-job) | +| Sentinel | 1.8.4 | 流量控制组件 | https://github.com/alibaba/Sentinel | [进入](https://github.com/alibaba/Sentinel/wiki/%E4%B8%BB%E9%A1%B5) | | Undertow | 2.2.17.Final | Java 开发的高性能 Web 服务器 | https://undertow.io | [进入](https://undertow.io/documentation.html) | | Docker | - | 应用容器引擎 | https://www.docker.com/ | - | | Jenkins | - | 自动化部署工具 | https://github.com/jenkinsci/jenkins | - | diff --git a/src/main/java/io/github/xxyopen/novel/core/interceptor/FlowLimitInterceptor.java b/src/main/java/io/github/xxyopen/novel/core/interceptor/FlowLimitInterceptor.java index f8c22f2..0ca5ee2 100644 --- a/src/main/java/io/github/xxyopen/novel/core/interceptor/FlowLimitInterceptor.java +++ b/src/main/java/io/github/xxyopen/novel/core/interceptor/FlowLimitInterceptor.java @@ -41,15 +41,15 @@ public class FlowLimitInterceptor implements HandlerInterceptor { private final ObjectMapper objectMapper; /** - * 定义一个对所有的请求进行统一限制的资源 + * novel 项目所有的资源 */ - private static final String ALL_LIMIT_RESOURCE = "allLimitResource"; + private static final String NOVEL_RESOURCE = "novelResource"; static { // 接口限流规则:所有的请求,限制每秒最多只能通过 2000 个,超出限制匀速排队 List rules = new ArrayList<>(); FlowRule rule1 = new FlowRule(); - rule1.setResource(ALL_LIMIT_RESOURCE); + rule1.setResource(NOVEL_RESOURCE); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); // Set limit QPS to 2000. rule1.setCount(2000); @@ -58,11 +58,11 @@ public class FlowLimitInterceptor implements HandlerInterceptor { FlowRuleManager.loadRules(rules); // 接口防刷规则 1:所有的请求,限制每个 IP 每秒最多只能通过 50 个,超出限制直接拒绝 - ParamFlowRule rule2 = new ParamFlowRule(ALL_LIMIT_RESOURCE) + ParamFlowRule rule2 = new ParamFlowRule(NOVEL_RESOURCE) .setParamIdx(0) .setCount(50); // 接口防刷规则 2:所有的请求,限制每个 IP 每分钟最多只能通过 1000 个,超出限制直接拒绝 - ParamFlowRule rule3 = new ParamFlowRule(ALL_LIMIT_RESOURCE) + ParamFlowRule rule3 = new ParamFlowRule(NOVEL_RESOURCE) .setParamIdx(0) .setCount(1000) .setDurationInSec(60); @@ -77,7 +77,7 @@ public class FlowLimitInterceptor implements HandlerInterceptor { // 若需要配置例外项,则传入的参数只支持基本类型。 // EntryType 代表流量类型,其中系统规则只对 IN 类型的埋点生效 // count 大多数情况都填 1,代表统计为一次调用。 - entry = SphU.entry(ALL_LIMIT_RESOURCE, EntryType.IN, 1, ip); + entry = SphU.entry(NOVEL_RESOURCE, EntryType.IN, 1, ip); // Your logic here. return HandlerInterceptor.super.preHandle(request, response, handler); } catch (BlockException ex) {