From 782cf5c33a7b3a586cb1089a163713dcb8c4ef76 Mon Sep 17 00:00:00 2001 From: wangye <1031205858@qq.com> Date: Thu, 8 Feb 2024 14:09:53 +0800 Subject: [PATCH] rich doc and linter --- apisix/plugins/limit-req/util.lua | 2 -- docs/en/latest/plugins/limit-req.md | 2 +- docs/zh/latest/plugins/limit-req.md | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apisix/plugins/limit-req/util.lua b/apisix/plugins/limit-req/util.lua index cc96f1c9be84..885acb642789 100644 --- a/apisix/plugins/limit-req/util.lua +++ b/apisix/plugins/limit-req/util.lua @@ -16,7 +16,6 @@ -- local math = require "math" local abs = math.abs -local floor = math.floor local max = math.max local ngx_now = ngx.now local ngx_null = ngx.null @@ -28,7 +27,6 @@ local _M = {version = 0.1} function _M.incoming(self, red, key, commit) local rate = self.rate local now = ngx_now() * 1000 - local conf = self.conf key = "limit_req" .. ":" .. key local excess_key = key .. "excess" diff --git a/docs/en/latest/plugins/limit-req.md b/docs/en/latest/plugins/limit-req.md index 317c00be5372..0e2dc13b8f92 100644 --- a/docs/en/latest/plugins/limit-req.md +++ b/docs/en/latest/plugins/limit-req.md @@ -44,7 +44,7 @@ The `limit-req` Plugin limits the number of requests to your service using the [ | rejected_code | string | False | 503 | [200,...,599] | HTTP status code returned when the requests exceeding the threshold are rejected. | | rejected_msg | string | False | | non-empty | Body of the response returned when the requests exceeding the threshold are rejected. | | allow_degradation | boolean | False | false | | When set to `true` enables Plugin degradation when the Plugin is temporarily unavailable and allows requests to continue. | -| policy | string | False | shared-dict | shared-dict, redis, redis-cluster | counter type to choose shared-dict, redis or redis-cluster | +| policy | string | False | "local" | ["local", "redis", "redis-cluster"] | Rate-limiting policies to use for retrieving and increment the limit count. When set to `local` the counters will be locally stored in memory on the node. When set to `redis` counters are stored on a Redis server and will be shared across the nodes. It is done usually for global speed limiting, and setting to `redis-cluster` uses a Redis cluster instead of a single instance. | | redis_host | string | required when `policy` is `redis` | | | Address of the Redis server. Used when the `policy` attribute is set to `redis`. | | redis_port | integer | False | 6379 | [1,...] | Port of the Redis server. Used when the `policy` attribute is set to `redis`. | | redis_username | string | False | | | Username for Redis authentication if Redis ACL is used (for Redis version >= 6.0). If you use the legacy authentication method `requirepass` to configure Redis password, configure only the `redis_password`. Used when the `policy` is set to `redis`. | diff --git a/docs/zh/latest/plugins/limit-req.md b/docs/zh/latest/plugins/limit-req.md index 8f2aa7b1b1b4..dd6461d0edbd 100644 --- a/docs/zh/latest/plugins/limit-req.md +++ b/docs/zh/latest/plugins/limit-req.md @@ -43,7 +43,7 @@ description: limit-req 插件使用漏桶算法限制对用户服务的请求速 | rejected_msg | string | 否 | | 非空 | 当超过阈值的请求被拒绝时,返回的响应体。| | nodelay | boolean | 否 | false | | 当设置为 `true` 时,请求速率超过 `rate` 但没有超过(`rate` + `burst`)的请求不会加上延迟;当设置为 `false`,则会加上延迟。 | | allow_degradation | boolean | 否 | false | | 当设置为 `true` 时,如果限速插件功能临时不可用,将会自动允许请求继续。| -| policy | string | 否 | shared-dict | shared-dict, redis, redis-cluster | 计数器类型 | +| policy | string | 否 | "local" | ["local", "redis", "redis-cluster"] | 用于检索和增加限制计数的策略。当设置为 `local` 时,计数器被以内存方式保存在节点本地;当设置为 `redis` 时,计数器保存在 Redis 服务节点上,从而可以跨节点共享结果,通常用它来完成全局限速;当设置为 `redis-cluster` 时,使用 Redis 集群而不是单个实例。| | redis_host | string | 否 | | | 当使用 `redis` 限速策略时,Redis 服务节点的地址。**当 `policy` 属性设置为 `redis` 时必选。** | | redis_port | integer | 否 | 6379 | [1,...] | 当使用 `redis` 限速策略时,Redis 服务节点的端口。 | | redis_username | string | 否 | | | 若使用 Redis ACL 进行身份验证(适用于 Redis 版本 >=6.0),则需要提供 Redis 用户名。若使用 Redis legacy 方式 `requirepass` 进行身份验证,则只需将密码配置在 `redis_password`。当 `policy` 设置为 `redis` 时使用。 |