-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin refactor and refresh on SIGHUP #143
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #143 +/- ##
==========================================
- Coverage 41.85% 41.29% -0.56%
==========================================
Files 14 14
Lines 743 770 +27
==========================================
+ Hits 311 318 +7
- Misses 387 407 +20
Partials 45 45
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
2a29f01
to
e74ff94
Compare
…ement this allows for keeping arbitrary state inside the plugin that can be leveraged in the refresh functions that are called on SIGHUP Signed-off-by: Reinier Schoof <reinier@skoef.nl>
Apart from the whole SIGHUP/refresh feature, the refactor of the plugin into an interface seems like a good idea to me anyway. That way you can easily keep state of the instance of the plugin instead of the plugin globally. For instance the DNS plugin has two global variables, Also, I can see a ratelimit plugin happening easily this way, the instance of the plugin could keep track of requests per MAC address and you wouldn't have to create a global variable per plugin instance for that. |
I'm not really convinced by the plugin-as-interface refactor at this point
That's already possible! There are 2 different things here: A more useful refactor here imo would be to make the handlers returned by the setup functions, either concrete structs or interfaces rather than just a single function
Absolutely agree, that's been a desired improvement for a while
It is already possible (see above / the prefix plugin). I'd argue the current change doesn't make it easier at all: in main, you now need to create the plugin objects, before parsing the configuration but they now also hold the plugin instance state. To spawn the same plugin twice if the per-plugin Plugin object holds state, you now need to create the Plugin objects multiple times; instead of the current state where just calling setup[46] multiple times for a plugin that supports it will give you independent instances |
rewrote Plugin object to an interface that every plugin needs to implement
this allows for keeping arbitrary state inside the plugin that can be leveraged
in the refresh functions that are called on SIGHUP
NOTE: this PR is merely an idea, but I wanted to propose reimplementing the plugin structure.