Skip to content

Commit

Permalink
rich doc and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
theweakgod committed Feb 8, 2024
1 parent 4219d33 commit 782cf5c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions apisix/plugins/limit-req/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/limit-req.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/latest/plugins/limit-req.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 时使用。 |
Expand Down

0 comments on commit 782cf5c

Please sign in to comment.