Sentinel
Sentinel copied to clipboard
Refactor the underlying model of SystemRuleManager
Describe what this PR does / why we need it
重构 SystemRule, 参考了 sentinel-golang 对 SystemRule 的实现, 一个系统规则对应一个指标条件
Does this pull request fix one issue?
Fixes #3143 #3084 #3148
Describe how you did it
- 一个系统规则对应一个条件, 系统规则包含类型和触发值 (SystemMetricType 和 triggerCount)
- 简化 SystemRuleManager 职责, 只负责进行规则的校验和加载
- 增加 SystemRuleChecker 负责根据规则去判断当前请求是否触发阈值
Describe how to verify it
运行单元测试
- com.alibaba.csp.sentinel.slots.block.system.SystemRuleTest
- com.alibaba.csp.sentinel.slots.system.SystemRuleManagerTest 运行验证 demo com.alibaba.csp.sentinel.demo.system.SystemGuardDemo#main()