theweakgod commented on code in PR #10866:
URL: https://github.com/apache/apisix/pull/10866#discussion_r1469345992
##########
apisix/plugins/limit-conn/limit-conn-redis-cluster.lua:
##########
@@ -0,0 +1,158 @@
+local rediscluster = require("resty.rediscluster")
+local core = require("apisix.core")
+local assert = assert
+local setmetatable = setmetatable
+local math = require "math"
+local floor = math.floor
+local ipairs = ipairs
+local ngx_timer_at = ngx.timer.at
+
+local _M = {version = 0.1}
+
+
+local mt = {
+ __index = _M
+}
+
+
+local function new_redis_cluster(conf)
Review Comment:
In order to distinguish redis and redis-cluster, I will create two new files
in apisix/utils/. One is redis.lua and the other is redis-cluster.lua. what you
think?
##########
apisix/plugins/limit-conn.lua:
##########
@@ -19,18 +19,95 @@ local limit_conn = require("apisix.plugins.limit-conn.init")
local plugin_name = "limit-conn"
+
+local counter_type_to_additional_properties = {
+ redis = {
+ properties = {
+ redis_host = {
+ type = "string", minLength = 2
+ },
+ redis_port = {
+ type = "integer", minimum = 1, default = 6379,
+ },
+ redis_username = {
+ type = "string", minLength = 1,
+ },
+ redis_password = {
+ type = "string", minLength = 0,
+ },
+ redis_prefix = {
+ type = "string", minLength = 0, default = "limit_conn",
pattern = "^[0-9a-zA-Z|_]+$"
+ },
+ redis_database = {
+ type = "integer", minimum = 0, default = 0,
+ },
+ redis_timeout = {
+ type = "integer", minimum = 1, default = 1000,
+ },
+ redis_ssl = {
+ type = "boolean", default = false,
+ },
+ redis_ssl_verify = {
+ type = "boolean", default = false,
+ },
+ },
+ required = {"redis_host"},
+ },
+ ["shared-dict"] = {
+ properties = {
+ },
+ },
+ ["redis-cluster"] = {
+ properties = {
+ redis_cluster_nodes = {
+ type = "array",
+ minItems = 2,
+ items = {
+ type = "string", minLength = 2, maxLength = 100
+ },
+ },
+ redis_password = {
+ type = "string", minLength = 0,
+ },
+ redis_prefix = {
+ type = "string", minLength = 0, default = "limit_conn",
pattern = "^[0-9a-zA-Z|_]+$"
+ },
+ redis_timeout = {
+ type = "integer", minimum = 1, default = 1000,
+ },
+ redis_cluster_name = {
+ type = "string",
+ },
+ redis_cluster_ssl = {
+ type = "boolean", default = false,
+ },
+ redis_cluster_ssl_verify = {
+ type = "boolean", default = false,
+ },
+ },
+ required = {"redis_cluster_nodes", "redis_cluster_name"},
+ },
+}
local schema = {
type = "object",
properties = {
- conn = {type = "integer", exclusiveMinimum = 0},
+ conn = {type = "integer", exclusiveMinimum = 0}, --
limit.conn max
burst = {type = "integer", minimum = 0},
default_conn_delay = {type = "number", exclusiveMinimum = 0},
only_use_default_delay = {type = "boolean", default = false},
- key = {type = "string"},
- key_type = {type = "string",
+ key = {
+ type = "string"
+ },
+ key_type = {
+ type = "string",
enum = {"var", "var_combination"},
default = "var",
},
+ counter_type = {
Review Comment:
Ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]