docs: update README.md

This commit is contained in:
xiongxiaoyang 2022-06-01 14:11:58 +08:00
parent 7f0d6c842a
commit c4fabe2ca1
2 changed files with 8 additions and 7 deletions

View File

@ -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) | | 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) | | 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) | | 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) | | Undertow | 2.2.17.Final | Java 开发的高性能 Web 服务器 | https://undertow.io | [进入](https://undertow.io/documentation.html) |
| Docker | - | 应用容器引擎 | https://www.docker.com/ | - | | Docker | - | 应用容器引擎 | https://www.docker.com/ | - |
| Jenkins | - | 自动化部署工具 | https://github.com/jenkinsci/jenkins | - | | Jenkins | - | 自动化部署工具 | https://github.com/jenkinsci/jenkins | - |

View File

@ -41,15 +41,15 @@ public class FlowLimitInterceptor implements HandlerInterceptor {
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
/** /**
* 定义一个对所有的请求进行统一限制的资源 * novel 项目所有的资源
*/ */
private static final String ALL_LIMIT_RESOURCE = "allLimitResource"; private static final String NOVEL_RESOURCE = "novelResource";
static { static {
// 接口限流规则所有的请求限制每秒最多只能通过 2000 超出限制匀速排队 // 接口限流规则所有的请求限制每秒最多只能通过 2000 超出限制匀速排队
List<FlowRule> rules = new ArrayList<>(); List<FlowRule> rules = new ArrayList<>();
FlowRule rule1 = new FlowRule(); FlowRule rule1 = new FlowRule();
rule1.setResource(ALL_LIMIT_RESOURCE); rule1.setResource(NOVEL_RESOURCE);
rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS);
// Set limit QPS to 2000. // Set limit QPS to 2000.
rule1.setCount(2000); rule1.setCount(2000);
@ -58,11 +58,11 @@ public class FlowLimitInterceptor implements HandlerInterceptor {
FlowRuleManager.loadRules(rules); FlowRuleManager.loadRules(rules);
// 接口防刷规则 1所有的请求限制每个 IP 每秒最多只能通过 50 超出限制直接拒绝 // 接口防刷规则 1所有的请求限制每个 IP 每秒最多只能通过 50 超出限制直接拒绝
ParamFlowRule rule2 = new ParamFlowRule(ALL_LIMIT_RESOURCE) ParamFlowRule rule2 = new ParamFlowRule(NOVEL_RESOURCE)
.setParamIdx(0) .setParamIdx(0)
.setCount(50); .setCount(50);
// 接口防刷规则 2所有的请求限制每个 IP 每分钟最多只能通过 1000 超出限制直接拒绝 // 接口防刷规则 2所有的请求限制每个 IP 每分钟最多只能通过 1000 超出限制直接拒绝
ParamFlowRule rule3 = new ParamFlowRule(ALL_LIMIT_RESOURCE) ParamFlowRule rule3 = new ParamFlowRule(NOVEL_RESOURCE)
.setParamIdx(0) .setParamIdx(0)
.setCount(1000) .setCount(1000)
.setDurationInSec(60); .setDurationInSec(60);
@ -77,7 +77,7 @@ public class FlowLimitInterceptor implements HandlerInterceptor {
// 若需要配置例外项则传入的参数只支持基本类型 // 若需要配置例外项则传入的参数只支持基本类型
// EntryType 代表流量类型其中系统规则只对 IN 类型的埋点生效 // EntryType 代表流量类型其中系统规则只对 IN 类型的埋点生效
// count 大多数情况都填 1代表统计为一次调用 // count 大多数情况都填 1代表统计为一次调用
entry = SphU.entry(ALL_LIMIT_RESOURCE, EntryType.IN, 1, ip); entry = SphU.entry(NOVEL_RESOURCE, EntryType.IN, 1, ip);
// Your logic here. // Your logic here.
return HandlerInterceptor.super.preHandle(request, response, handler); return HandlerInterceptor.super.preHandle(request, response, handler);
} catch (BlockException ex) { } catch (BlockException ex) {