-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
Issue description
Current situation
At the moment, you add a plugin in the request flow by referencing with its name and setting the configuration. The plugin is effectively a singleton.
This approach has some downsides:
- You can use a plugin only once in the request flow. Users cannot add the same plugin multiple times with different configurations.
- For maintainers, it means that they need to duplicate code and reference it with different names and priorities. For example, the ext-plugin-pre-req and the ext-plugin-post-req do the same - run arbitrary Lua code.
- Users cannot change the priority of a plugin, it's hard-coded (see feat: As a User, I want to be able to configure the priority of each plugin so I don't need to change the source code #6504)
- Plugin developers need to handle every possible configuration case (see request help: How to current limit both in minutes and day by using plugin limit-count #6197)
Proposal
In Object-Oriented speak, make Plugin
a class and introduce PluginInstance
"objects" (or something similarly named):
Plugin
defines the codePluginInstance
references thePlugin
and associates it with a priority and a configuration
Decoupling the code from the configuration/priority would bring much more freedom for users.
liangliang4ward, fatihbm, nic-chen, nic-6443 and stubbornTanzhebzp2010, juzhiyuan, leslie-tsang, liangliang4ward, shuaijinchao and 4 more