From fd95058bf87d76654f0282a3c3f3ef38e0d5e1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hans=20H=C3=BCbner?= Date: Sat, 9 Sep 2023 07:22:51 +0200 Subject: [PATCH] refactor(core): remove plugin init() function The init() function added in ea85db83ebd0aa2fed00531aa7fb7b8d56edadd0 was perceived to have too little overall value. It is thus removed. --- kong/db/dao/plugins.lua | 25 ------------------------- kong/init.lua | 2 -- 2 files changed, 27 deletions(-) diff --git a/kong/db/dao/plugins.lua b/kong/db/dao/plugins.lua index 9bf8447ef047..8a284c81d7d2 100644 --- a/kong/db/dao/plugins.lua +++ b/kong/db/dao/plugins.lua @@ -355,29 +355,4 @@ function Plugins:get_handlers() return list end -function Plugins:execute_plugin_init() - local handlers, err = self:get_handlers() - if not handlers then - return nil, err - end - - local errors - - for _, handler in ipairs(handlers) do - if implements(handler.handler, "init") then - local ok, err = pcall(handler.handler.init, handler.handler) - if not ok then - errors = errors or {} - errors[#errors + 1] = "on plugin '" .. handler.name .. "': " .. tostring(err) - end - end - end - - if errors then - return nil, "error executing plugin init: " .. table.concat(errors, "; ") - end - - return true -end - return Plugins diff --git a/kong/init.lua b/kong/init.lua index ff1a30fbf894..b4742a7cb5dd 100644 --- a/kong/init.lua +++ b/kong/init.lua @@ -627,8 +627,6 @@ function Kong.init() -- Load plugins as late as possible so that everything is set up assert(db.plugins:load_plugin_schemas(config.loaded_plugins)) - assert(db.plugins:execute_plugin_init()) - if is_stream_module then stream_api.load_handlers() end