Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

Refactor the underlying model of SystemRuleManager

Open huang-gz opened this issue 1 year ago • 0 comments

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

  1. 一个系统规则对应一个条件, 系统规则包含类型和触发值 (SystemMetricType 和 triggerCount)
  2. 简化 SystemRuleManager 职责, 只负责进行规则的校验和加载
  3. 增加 SystemRuleChecker 负责根据规则去判断当前请求是否触发阈值

Describe how to verify it

运行单元测试

  1. com.alibaba.csp.sentinel.slots.block.system.SystemRuleTest
  2. com.alibaba.csp.sentinel.slots.system.SystemRuleManagerTest 运行验证 demo com.alibaba.csp.sentinel.demo.system.SystemGuardDemo#main()

Special notes for reviews

huang-gz avatar Jun 29 '23 12:06 huang-gz