This is an automated email from the ASF dual-hosted git repository.
ashishtiwari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 44391e0d9 refactor: workflow plugin registeration (#11832)
44391e0d9 is described below
commit 44391e0d90791a5b454926849b7c6119184a8bc4
Author: Ashish Tiwari <[email protected]>
AuthorDate: Tue Dec 17 14:23:16 2024 +0530
refactor: workflow plugin registeration (#11832)
---
apisix/plugin.lua | 4 ++++
apisix/plugins/limit-count.lua | 10 ++++++++++
apisix/plugins/workflow.lua | 16 +++++++---------
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index dc22459aa..90d26f4ae 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -185,6 +185,10 @@ local function load_plugin(name, plugins_list, plugin_type)
plugin.init()
end
+ if plugin.workflow_handler then
+ plugin.workflow_handler()
+ end
+
return
end
diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index e3b4c0f6c..ab7c532a5 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -16,6 +16,7 @@
--
local fetch_secrets = require("apisix.secret").fetch_secrets
local limit_count = require("apisix.plugins.limit-count.init")
+local workflow = require("apisix.plugins.workflow")
local plugin_name = "limit-count"
local _M = {
@@ -36,5 +37,14 @@ function _M.access(conf, ctx)
return limit_count.rate_limit(conf, ctx, plugin_name, 1)
end
+function _M.workflow_handler()
+ workflow.register(plugin_name,
+ function (conf, ctx)
+ return limit_count.rate_limit(conf, ctx, plugin_name, 1)
+ end,
+ function (conf)
+ return limit_count.check_schema(conf)
+ end)
+end
return _M
diff --git a/apisix/plugins/workflow.lua b/apisix/plugins/workflow.lua
index bf5221dd1..e41679ba0 100644
--- a/apisix/plugins/workflow.lua
+++ b/apisix/plugins/workflow.lua
@@ -15,7 +15,6 @@
-- limitations under the License.
--
local core = require("apisix.core")
-local limit_count = require("apisix.plugins.limit-count.init")
local expr = require("resty.expr.v1")
local ipairs = ipairs
@@ -93,23 +92,22 @@ local function exit(conf)
end
-local function rate_limit(conf, ctx)
- return limit_count.rate_limit(conf, ctx, "limit-count", 1)
-end
-
local support_action = {
["return"] = {
handler = exit,
check_schema = check_return_schema,
- },
- ["limit-count"] = {
- handler = rate_limit,
- check_schema = limit_count.check_schema,
}
}
+function _M.register(plugin_name, handler, check_schema)
+ support_action[plugin_name] = {
+ handler = handler,
+ check_schema = check_schema
+ }
+end
+
function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then