-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resource rules (flow/degrade/param/authority) support regex matching #3251
Conversation
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/RuleManager.java
Outdated
Show resolved
Hide resolved
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/RuleManager.java
Show resolved
Hide resolved
cf4e8c5
to
afd167a
Compare
It would be helpful to have a benchmark report comparing the original rules. 🚀 |
Throughput (s)Throughput (ns)AverageTime (ns)
Due to the need to retrieve rules from the regex cache map and regular rules, the throughput of the previous retrieval method is twice that of direct retrieval, which means there is an additional get method, but it is also within an acceptable range. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for contributing! 🚀 |
Describe what this PR does / why we need it
Resource rules support matching resource names according to regular rules, allowing users to configure traffic limiting rules or batch configuration.
When adding/deleting interfaces, there is no need to manually create/delete rules.
资源规则支持按照正则匹配资源名称,允许用户按照配置兜底限流规则或批量配置的能力。
当新增/删除接口时,无需手动创建/删除规则。
Does this pull request fix one issue?
Fixes #3247
Describe how you did it
Add a RuleManger to uniformly manage ordinary rules and regular rules. In order to reduce the performance loss caused by regular parsing/matching, the following two methods are used:
增加一个 RuleManger 统一管理普通规则和正则规则,为了减少正则解析/匹配所带来的性能损耗,使用下面两种方式:
Describe how to verify it
Regular unit tests have been added to each of the four rules to ensure normal performance; if regular rules are turned on, current limiting rules that meet regular matching but have different resource names will take effect.
对四种规则分别增加了正则的单元测试,用于保证表现正常;如果开启了正则规则,满足正则匹配但资源名称不同的限流规则均会生效。
Special notes for reviews
None