feat(plugins): add a bit of documentation
Steven Allen committed
Jun 28, 2019 at 08:47 UTC
a9f749014912ad4e3862bdfc52bfa3e861463278
1 file changed
+11
-1
plugin/loader/loader.go
+11
-1
@@ -63,7 +63,15 @@ func (ls loaderState) String() string {
63
}
64
}
65
66
-// PluginLoader keeps track of loaded plugins
66
+// PluginLoader keeps track of loaded plugins.
67
+//
68
+// To use:
69
+// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
70
+// will automatically be loaded.
71
+// 2. Call Initialize to run all initialization logic.
72
+// 3. Call Inject to register the plugins.
73
+// 4. Optionally call Start to start plugins.
74
+// 5. Call Close to close all plugins.
75
type PluginLoader struct {
76
state loaderState
77
plugins map[string]plugin.Plugin
@@ -96,6 +104,7 @@ func (loader *PluginLoader) transition(from, to loaderState) error {
104
return nil
105
}
106
107
+// Load loads a plugin into the plugin loader.
108
func (loader *PluginLoader) Load(pl plugin.Plugin) error {
109
if err := loader.assertState(loaderLoading); err != nil {
110
return err
@@ -113,6 +122,7 @@ func (loader *PluginLoader) Load(pl plugin.Plugin) error {
122
return nil
123
}
124
125
+// LoadDirectory loads a directory of plugins into the plugin loader.
126
func (loader *PluginLoader) LoadDirectory(pluginDir string) error {
127
if err := loader.assertState(loaderLoading); err != nil {
128
return err