-
Notifications
You must be signed in to change notification settings - Fork 534
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 limit-count plugin #1739
Conversation
Please add your description for this PR |
Codecov Report
@@ Coverage Diff @@
## master #1739 +/- ##
==========================================
+ Coverage 72.57% 72.79% +0.21%
==========================================
Files 113 114 +1
Lines 2695 2727 +32
Branches 650 655 +5
==========================================
+ Hits 1956 1985 +29
- Misses 739 742 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Deploy preview for apisix-dashboard ready! Built with commit d896705 |
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.
Please update this PR's description
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.policy.tooltip' })} | ||
> | ||
<Select onChange={(e: PolicyProps) => { setPoicy(e) }}> | ||
{["local", "redis", "redis-cluster"].map(item => (<Select.Option value={item}>{item}</Select.Option>))} |
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
redis_host: '127.0.0.1', | ||
redis_password: 'redis_password', | ||
redis_cluster_name: 'redis_cluster_name', | ||
redis_cluster_nodes_0: "redis.cluster1", | ||
redis_cluster_nodes_1: "redis.cluster1", |
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.
What are these default values?
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.
Not a good default values, will update later
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.
updated.
web/cypress/integration/consumer/create-consumer-with-limit-count-plugin-form.spec.js
Show resolved
Hide resolved
// limit-count | ||
'component.pluginForm.limit-count.count.tooltip': '指定时间窗口内的请求数量阈值。', | ||
'component.pluginForm.limit-count.time_window.tooltip': '时间窗口的大小(以秒为单位),超过这个时间就会重置。', | ||
'component.pluginForm.limit-count.key.tooltip': '用来做请求计数的有效值。例如,可以使用主机名(或服务器区域)作为关键字,以便限制每个主机名规定时间内的请求次数。我们也可以使用客户端地址作为关键字,这样我们就可以避免单个客户端规定时间内多次的连接我们的服务。当前接受的 key 有:"remote_addr"(客户端 IP 地址), "server_addr"(服务端 IP 地址), 请求头中的"X-Forwarded-For" 或 "X-Real-IP", "consumer_name"(consumer 的 username), "service_id" 。', |
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.
May I ask what is the meaning of 服务器区域
?
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.
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.
just use 服务器地址
Tks for your report. I will check it. |
@liuxiran fixed. |
|
||
return (<> | ||
<Form.Item | ||
label="redis_host" |
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.
emmm would better have i18n
for those fields, for users may not know what's it
<Form.Item | ||
label="rejected_code" | ||
name="rejected_code" | ||
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.rejected_code.tooltip' })} |
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.
default value is 503
name="redis_port" | ||
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_port.tooltip' })} | ||
> | ||
<InputNumber min={1} /> |
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.
<InputNumber min={1} /> | |
<InputNumber min={1} max={65535} /> |
<Form | ||
form={form} | ||
{...FORM_ITEM_LAYOUT} | ||
initialValues={{ key: 'remote_addr', redis_cluster_nodes: ['', ''], policy, redis_port: 6379, redis_database: 0, redis_timeout: 1000 }} |
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.
When you submit data and use local policy, will redis_port be 6379?
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.
No, it won't.
name="redis_timeout" | ||
tooltip={formatMessage({ id: 'component.pluginForm.limit-count.redis_timeout.tooltip' })} | ||
> | ||
<InputNumber /> |
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.
min = 1
</>) | ||
} | ||
|
||
const RedisClusterForm: React.FC<Props> = () => { |
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.
What do these Props for?
|
||
return ( | ||
<> | ||
<Form.Item |
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.
missing two fields: redis_timeout & redis_password.
https://github.com/apache/apisix/blob/master/apisix/plugins/limit-count.lua#L37
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.
Don't forget to resolve those comments :)
Please answer these questions before submitting a pull request, or your PR will get closed.
Why submit this pull request?
What changes will this PR take into?
Please update this section with detailed description.
Checklist: