AlinsRan commented on code in PR #13444: URL: https://github.com/apache/apisix/pull/13444#discussion_r3309380024
########## apisix/plugins/toolset/init.lua: ########## @@ -0,0 +1,170 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +local pairs = pairs +local core = require("apisix.core") +local ngx = ngx +local cache = core.table.new(0, 32) +local stop_timer = false +local load, unload = "load", "unload" +local package = package +local pcall = pcall +local require = require +local string = string + +local _M = { + version = 0.1, + priority = 22901, + name = "toolset", + schema = {}, + scope = "global", +} + + +local function get_plugin_config() + -- clear cache to reload + package.loaded["apisix.plugins.toolset.config"] = nil + local loaded, plugins_config = pcall(require, "apisix.plugins.toolset.config") + if loaded and plugins_config == true then + core.log.warn("empty plugin config file") + return nil + end + if not loaded then + core.log.error("failed to load plugin config: ", plugins_config) + return nil + end + return plugins_config +end Review Comment: Thanks for the suggestion! The `config.lua` approach is intentional: the plugin acts as a diagnostic tool that needs to be toggled on/off quickly without restarting APISIX or modifying `config.yaml`. By polling `apisix/plugins/toolset/config.lua` every second (via `package.loaded` eviction + re-require), operators can enable/disable sub-plugins with a simple file edit, and the change takes effect within 1 second. The docs and `plugin_attr` examples have been removed in the latest commit to avoid confusion — the docs now correctly document the `config.lua` editing approach. -- 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]
