You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2022/02/23 01:53:57 UTC
[apisix-dashboard] branch master updated: feat: Add more fields to limit-count plugin (#2322)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new fd44364 feat: Add more fields to limit-count plugin (#2322)
fd44364 is described below
commit fd44364d2563aac83e2ad8f4a340fc64af4375d3
Author: oil欧呦 <22...@qq.com>
AuthorDate: Wed Feb 23 09:53:52 2022 +0800
feat: Add more fields to limit-count plugin (#2322)
---
...eate-route-with-limit-count-plugin-form.spec.js | 2 ++
web/src/components/Plugin/UI/limit-count.tsx | 31 +++++++++++++++++++++-
web/src/components/Plugin/locales/en-US.ts | 6 +++++
web/src/components/Plugin/locales/zh-CN.ts | 6 +++++
4 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js b/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js
index bf5814f..e2a2ad4 100644
--- a/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js
+++ b/web/cypress/integration/route/create-route-with-limit-count-plugin-form.spec.js
@@ -36,6 +36,7 @@ context('Create and delete route with limit-count form', () => {
key: '#key',
rejected_code: '#rejected_code',
policy: '#policy',
+ group: '#group',
redis_host: '#redis_host',
redis_port: '#redis_port',
redis_password: '#redis_password',
@@ -85,6 +86,7 @@ context('Create and delete route with limit-count form', () => {
cy.get(selector.count).type(1);
cy.get(selector.time_window).type(1);
cy.get(selector.rejected_code).type(500);
+ cy.get(selector.group).type('test_group');
cy.get(selector.drawer).within(() => {
cy.contains('Submit').click({
force: true,
diff --git a/web/src/components/Plugin/UI/limit-count.tsx b/web/src/components/Plugin/UI/limit-count.tsx
index adb384f..51ecd53 100644
--- a/web/src/components/Plugin/UI/limit-count.tsx
+++ b/web/src/components/Plugin/UI/limit-count.tsx
@@ -16,7 +16,7 @@
*/
import React, { useState } from 'react';
import type { FormInstance } from 'antd/es/form';
-import { Button, Col, Form, Input, InputNumber, Row, Select } from 'antd';
+import { Button, Col, Form, Input, InputNumber, Row, Select, Switch } from 'antd';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { useIntl } from 'umi';
@@ -324,6 +324,35 @@ const LimitCount: React.FC<Props> = ({ form, schema }) => {
</Select>
</Form.Item>
<Form.Item
+ label="group"
+ name="group"
+ tooltip={formatMessage({ id: 'component.pluginForm.limit-count.key.tooltip' })}
+ >
+ <Input />
+ </Form.Item>
+ <Form.Item
+ initialValue={properties.allow_degradation.default}
+ label="allow_degradation"
+ name="allow_degradation"
+ tooltip={formatMessage({
+ id: 'component.pluginForm.limit-count.allow_degradation.tooltip',
+ })}
+ valuePropName="checked"
+ >
+ <Switch />
+ </Form.Item>
+ <Form.Item
+ initialValue={properties.show_limit_quota_header.default}
+ label="show_limit_quota_header"
+ name="show_limit_quota_header"
+ tooltip={formatMessage({
+ id: 'component.pluginForm.limit-count.show_limit_quota_header.tooltip',
+ })}
+ valuePropName="checked"
+ >
+ <Switch />
+ </Form.Item>
+ <Form.Item
shouldUpdate={(prev, next) => prev.policy !== next.policy}
style={{ display: 'none' }}
>
diff --git a/web/src/components/Plugin/locales/en-US.ts b/web/src/components/Plugin/locales/en-US.ts
index 365e5b3..c7cefd9 100644
--- a/web/src/components/Plugin/locales/en-US.ts
+++ b/web/src/components/Plugin/locales/en-US.ts
@@ -132,6 +132,12 @@ export default {
'The HTTP status code returned when the request exceeds the threshold is rejected, default 503.',
'component.pluginForm.limit-count.policy.tooltip':
'The rate-limiting policies to use for retrieving and incrementing the limits. Available values are local(the counters will be stored locally in-memory on the node) and redis(counters are stored on a Redis server and will be shared across the nodes, usually use it to do the global speed limit) and redis-cluster(the same function as redis, only use Redis cluster pattern).',
+ 'component.pluginForm.limit-count.allow_degradation.tooltip':
+ 'Whether to enable plugin degradation when the limit-count function is temporarily unavailable(e.g. redis timeout). Allow requests to continue when the value is set to true',
+ 'component.pluginForm.limit-count.show_limit_quota_header.tooltip':
+ 'Whether show X-RateLimit-Limit and X-RateLimit-Remaining (which mean the total number of requests and the remaining number of requests that can be sent) in the response header',
+ 'component.pluginForm.limit-count.group.tooltip':
+ 'Route configured with the same group will share the same counter',
'component.pluginForm.limit-count.redis_host.tooltip':
'When using the redis policy, this property specifies the address of the Redis server.',
'component.pluginForm.limit-count.redis_port.tooltip':
diff --git a/web/src/components/Plugin/locales/zh-CN.ts b/web/src/components/Plugin/locales/zh-CN.ts
index 43f38c4..77d8a1d 100644
--- a/web/src/components/Plugin/locales/zh-CN.ts
+++ b/web/src/components/Plugin/locales/zh-CN.ts
@@ -124,6 +124,12 @@ export default {
'当请求超过阈值被拒绝时,返回的 HTTP 状态码。',
'component.pluginForm.limit-count.policy.tooltip':
'用于检索和增加限制的速率限制策略。可选的值有:local(计数器被以内存方式保存在节点本地,默认选项) 和 redis(计数器保存在 Redis 服务节点上,从而可以跨节点共享结果,通常用它来完成全局限速);以及redis-cluster,跟 redis 功能一样,只是使用 redis 集群方式。',
+ 'component.pluginForm.limit-count.allow_degradation.tooltip':
+ '当限流插件功能临时不可用时(例如,Redis 超时)是否允许请求继续。当值设置为 true 时则自动允许请求继续',
+ 'component.pluginForm.limit-count.show_limit_quota_header.tooltip':
+ '是否在响应头中显示 X-RateLimit-Limit 和 X-RateLimit-Remaining (限制的总请求数和剩余还可以发送的请求数)',
+ 'component.pluginForm.limit-count.group.tooltip':
+ '配置同样的 group 的 Route 将共享同样的限流计数器',
'component.pluginForm.limit-count.redis_host.tooltip':
'当使用 redis 限速策略时,该属性是 Redis 服务节点的地址。',
'component.pluginForm.limit-count.redis_port.tooltip':