-
Notifications
You must be signed in to change notification settings - Fork 570
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
feat:add wasm go key-rate-limit plugin #1751
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1751 +/- ##
==========================================
+ Coverage 35.91% 43.41% +7.50%
==========================================
Files 69 76 +7
Lines 11576 12278 +702
==========================================
+ Hits 4157 5331 +1174
+ Misses 7104 6617 -487
- Partials 315 330 +15 |
请求review(如果有时间的话) |
var tokenBucketPrefix string = "mse.token_bucket" | ||
|
||
// Key-prefix for token bucket last updated time. | ||
var lastRefilledPrefix string = "mse.last_refilled" |
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.
这两个是不是用const更好?
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.
已改
// Key-prefix for token bucket last updated time. | ||
var lastRefilledPrefix string = "mse.last_refilled" | ||
|
||
var ruleId int = 0 |
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.
这个作为 parseConfig 的一个局部变量是不是就够了?
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.
这里我想请教一下parseConfig在处理不同级别的规则,比如domain和ingress的rule是不是会分别调用parseconfig还是一次性调用,如果一次性调用的话ruleId作为parseConfig的局部变量就可以了。
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.
这里我想请教一下parseConfig在处理不同级别的规则,比如domain和ingress的rule是不是会分别调用parseconfig还是一次性调用,如果一次性调用的话ruleId作为parseConfig的局部变量就可以了。
不同粒度的配置是独立的解析的,不需要考虑覆盖。
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.
这里主要是想通过一个全局的ruleId来区分不同粒度下limit_key规则相同的情况,独立接卸的情况下ruleId如果作为parseConfig的一个局部变量是不是没法区分
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.
请 @johnlanni 看一下这种场景建议如何实现。
var initialValue uint64 = 0 | ||
for _, rule := range rules { | ||
lastRefilledKey := strconv.Itoa(rule.ruleId) + lastRefilledPrefix + rule.key | ||
tokenBucketKey := strconv.Itoa(rule.ruleId) + tokenBucketPrefix + rule.key |
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.
感觉可以给LimitItem加个函数生成这两个key
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.
已加
43726bd
to
c3c2627
Compare
PTAL @CH3CHO |
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.
暂时没有其他问题了
// Key-prefix for token bucket last updated time. | ||
var lastRefilledPrefix string = "mse.last_refilled" | ||
|
||
var ruleId int = 0 |
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.
请 @johnlanni 看一下这种场景建议如何实现。
Ⅰ. Describe what this PR did
实现wasm-go的本地key-rate-limit插件
Ⅱ. Does this pull request fix one issue?
#596
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews