-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: let plugins self-register (#1098)
# Description Refactors plugin registration such that Plugins self-register into the plugin Registry simply by their package being imported instead of being explicitly registered by external logic. This should look familiar as a Go plugin pattern as it's fundamentally the same as what's done in [Telegraf](https://github.com/influxdata/telegraf/blob/543b907cdf46d555afe083de846dc4ed055a4339/plugins/outputs/syslog/syslog.go#L191), [CoreDNS](https://github.com/coredns/coredns/blob/7429380b1cacebde73084ad3cb6fb676c69bd6b8/core/plugin/zplugin.go) (Caddy), and others. - Abuses `init()`s and aliasing to hide anything deeper than `pkg/plugin` from the rest of Retina, so that Plugins are more encapsulated. - Privatize the `Name` const in every Plugin since it no longer needs to be accessible from outside of their package. - Remove the `api.Name` type from the Plugin spec since it is redundant. Creating a string type like that is useful for enums, when you want to ensure at a data boundary that the string you're ingesting is one of your allowed values. Plugin names are self-provided consts and not used like this anyway, so it could only cause confusion. Removing it means we need to do many less type coercions. This also means we can pass around the plugin list from the conf (a []string) directly. ## Related Issue I was investigating making it possible for a Plugin to auto-detect that it should be enabled (via some auto-enable registry of detectFuncs, or similar) and wanted to clean this up first so to simplify that implementation. --------- Signed-off-by: Evan Baker <[email protected]>
- Loading branch information
Showing
40 changed files
with
340 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.