Skip to content
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: set minLength of redis_cluster_nodes to 1 for limit-count plugin #10612

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apisix/plugins/limit-count.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local limit_count = require("apisix.plugins.limit-count.init")

local plugin_name = "limit-count"
local _M = {
version = 0.4,
version = 0.5,
priority = 1002,
name = plugin_name,
schema = limit_count.schema,
Expand Down
2 changes: 1 addition & 1 deletion apisix/plugins/limit-count/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ local policy_to_additional_properties = {
type = "array",
minItems = 2,
items = {
type = "string", minLength = 2, maxLength = 100
type = "string", minLength = 1, maxLength = 100
},
},
redis_password = {
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/limit-count.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The `limit-count` Plugin limits the number of requests to your service by a give
| redis_ssl_verify | boolean | False | false | | If set to `true`, then verifies the validity of the server SSL certificate. Used when the `policy` attribute is set to `redis`. See [tcpsock:sslhandshake](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake). |
| redis_database | integer | False | 0 | redis_database >= 0 | Selected database of the Redis server (for single instance operation or when using Redis cloud with a single entrypoint). Used when the `policy` attribute is set to `redis`. |
| redis_timeout | integer | False | 1000 | [1,...] | Timeout in milliseconds for any command submitted to the Redis server. Used when the `policy` attribute is set to `redis` or `redis-cluster`. |
| redis_cluster_nodes | array | required when `policy` is `redis-cluster` | | | Addresses of Redis cluster nodes. Used when the `policy` attribute is set to `redis-cluster`. |
| redis_cluster_nodes | array | required when `policy` is `redis-cluster` | | from 1 to 100 nodes | Addresses of Redis cluster nodes. Used when the `policy` attribute is set to `redis-cluster`. |
| redis_cluster_name | string | required when `policy` is `redis-cluster` | | | Name of the Redis cluster service nodes. Used when the `policy` attribute is set to `redis-cluster`. |
| redis_cluster_ssl | boolean | False | false | | If set to `true`, then uses SSL to connect to redis-cluster. Used when the `policy` attribute is set to `redis-cluster`. |
| redis_cluster_ssl_verify | boolean | False | false | | If set to `true`, then verifies the validity of the server SSL certificate. Used when the `policy` attribute is set to `redis-cluster`. |
Expand Down
3 changes: 1 addition & 2 deletions t/plugin/limit-count-redis-cluster.t
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ __DATA__
"policy": "redis-cluster",
"redis_timeout": 1001,
"redis_cluster_nodes": [
"127.0.0.1:5000",
"127.0.0.1:5001"
"127.0.0.1:5000"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a new test case instead of change old one.
Better cover example in #10596 (comment), like

"limit-count": {
            "redis_cluster_nodes": [
              "redis-headless-service:6379"
            ],
        }

],
"redis_cluster_name": "redis-cluster-1"
}
Expand Down