feat(limit-count): add constant key type#5984
Conversation
See apache#5881 (comment) Signed-off-by: spacewander <[email protected]>
|
cc @zaunist @leslie-tsang @guoqqqi to have a check 😄 |
Co-authored-by: Yu.Bozhong <[email protected]>
| | time_window | integer | required | | time_window > 0 | the time window in seconds before the request count is reset. | | ||
| | key_type | string | optional | "var" | ["var", "var_combination"] | the type of key. | | ||
| | key_type | string | optional | "var" | ["var", "var_combination", "constant"] | the type of key. | | ||
| | key | string | optional | "remote_addr" | | the user specified key to limit the rate. If the `key_type` is "var", the key will be treated as a name of variable. If the `key_type` is "var_combination", the key will be a combination of variables. For example, if we use "$remote_addr $consumer_name" as keys, plugin will be restricted by two keys which are "remote_addr" and "consumer_name". If the value of the key is empty, `remote_addr` will be set as the default key.| |
There was a problem hiding this comment.
If possible, can we add a line here[L43] to document how the key will be interpreted when the key_type is constant?
There was a problem hiding this comment.
Addressed in the new commit
Signed-off-by: spacewander <[email protected]>
Co-authored-by: Bisakh <[email protected]>
| -- here we add a separator ':' to mark the boundary of the prefix and the key itself | ||
| if not conf.group then | ||
| key = key .. ctx.conf_type .. ctx.conf_version | ||
| key = ctx.conf_type .. ctx.conf_version .. ':' .. key | ||
| else | ||
| key = key .. conf.group | ||
| key = conf.group .. ':' .. key |
There was a problem hiding this comment.
I wonder if we should add a note here to alert those who use the key to monitoring or something else.
There was a problem hiding this comment.
Could you give an example for the note?
There was a problem hiding this comment.
How about:
-- key format changed from `key*` to `*:key` for constant key type supportThere was a problem hiding this comment.
Err...
I don't want to comment on all the changes in the code, unless it is something that affects public API. AFAIK, we don't describe the key format in the doc. So I think such change is just implementation details.
There was a problem hiding this comment.
Make Sense, leave the comment here should do the trick as well.
Signed-off-by: spacewander <[email protected]>
Co-authored-by: Yu.Bozhong <[email protected]> Co-authored-by: Bisakh <[email protected]>
See #5881 (comment)
Signed-off-by: spacewander [email protected]
What this PR does / why we need it:
Pre-submission checklist: