Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kayx23 committed Dec 30, 2024
1 parent 6130a10 commit b59b130
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/zh/latest/plugins/limit-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ description: limit-count 插件使用固定窗口算法,通过给定时间间
| count | integer || | > 0 | 给定时间间隔内允许的最大请求数。 |
| time_window | integer || | > 0 | 速率限制 `count` 对应的时间间隔(以秒为单位)。 |
| key_type | string || var | ["var","var_combination","constant"] | key 的类型。如果`key_type``var`,则 `key` 将被解释为变量。如果 `key_type``var_combination`,则 `key` 将被解释为变量的组合。如果 `key_type``constant`,则 `key` 将被解释为常量。 |
| key | string || remote_addr | | 用于计数请求的key 。如果 `key_type``var`,则 `key` 将被解释为变量。变量不需要以美元符号(`$`)为前缀。如果 `key_type``var_combination`,则 `key` 会被解释为变量的组合。所有变量都应该以美元符号 (`$`) 为前缀。例如,要配置 `key` 使用两个请求头 `custom-a``custom-b` 的组合,则 `key` 应该配置为 `$http_custom_a $http_custom_b`。如果 `key_type``constant`,则 `key` 会被解释为常量值。|
| key | string || remote_addr | | 用于计数请求的key。如果 `key_type``var`,则 `key` 将被解释为变量。变量不需要以美元符号(`$`)为前缀。如果 `key_type``var_combination`,则 `key` 会被解释为变量的组合。所有变量都应该以美元符号 (`$`) 为前缀。例如,要配置 `key` 使用两个请求头 `custom-a``custom-b` 的组合,则 `key` 应该配置为 `$http_custom_a $http_custom_b`。如果 `key_type``constant`,则 `key` 会被解释为常量值。|
| rejection_code | integer || 503 | [200,...,599] | 请求因超出阈值而被拒绝时返回的 HTTP 状态代码。|
| rejection_msg | string || | 非空 | 请求因超出阈值而被拒绝时返回的响应主体。|
| policy | string || local | ["local","re​​dis","re​​dis-cluster"] | 速率限制计数器的策略。如果是 `local`,则计数器存储在本地内存中。如果是 `redis`,则计数器存储在 Redis 实例上。如果是 `redis-cluster`,则计数器存储在 Redis 集群中。|
Expand All @@ -68,7 +68,7 @@ redis_cluster_name | string | 否 | | | | Redis 集群的名称。当 `policy`
| redis_cluster_ssl | boolean || false | | 如果为 `true`,当 `policy``redis-cluster`时,使用 SSL 连接 Redis 集群。|
| redis_cluster_ssl_verify | boolean || false | | 如果为 `true`,当 `policy``redis-cluster` 时,验证服务器 SSL 证书。 |

# 示例
## 示例

下面的示例演示了如何在不同情况下配置 `limit-count`

Expand Down Expand Up @@ -229,7 +229,7 @@ curl -i "http://127.0.0.1:9080/get" -H 'apikey: john-key'

以下示例通过配置 `limit-count` 插件的 `group` 演示了在多个路由之间共享速率限制配额。

请注意,同一 `group``limit-count` 插件的配置应该相同。 为了避免更新异常和重复配置,您可以创建一个带有 `limit-count` 插件和上游的服务,以供路由连接。
请注意,同一 `group``limit-count` 插件的配置应该相同。为了避免更新异常和重复配置,您可以创建一个带有 `limit-count` 插件和上游的服务,以供路由连接。

创建服务:

Expand Down Expand Up @@ -406,7 +406,7 @@ curl -i "http://127.0.0.1:9080/get"

以下示例演示了如何为常规和匿名消费者配置不同的速率限制策略,其中匿名消费者不需要进行身份验证并且配额较少。虽然此示例使用 [`key-auth`](./key-auth.md) 进行身份验证,但匿名消费者也可以使用 [`basic-auth`](./basic-auth.md)[`jwt-auth`](./jwt-auth.md)[`hmac-auth`](./hmac-auth.md) 进行配置。

创建一个消费者 `john`,并配置 `limit-count` 插件,以允许30秒内配额为3
创建一个消费者 `john`,并配置 `limit-count` 插件,以允许 30 秒内配额为 3

```shell
curl "http://127.0.0.1:9180/apisix/admin/consumers" -X PUT \
Expand Down

0 comments on commit b59b130

Please sign in to comment.