Skip to content

Commit

Permalink
feat(plugins): add a bit of documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jun 28, 2019
1 parent 4badef2 commit a9f7490
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugin/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,15 @@ func (ls loaderState) String() string {
}
}

// PluginLoader keeps track of loaded plugins
// PluginLoader keeps track of loaded plugins.
//
// To use:
// 1. Load any desired plugins with Load and LoadDirectory. Preloaded plugins
// will automatically be loaded.
// 2. Call Initialize to run all initialization logic.
// 3. Call Inject to register the plugins.
// 4. Optionally call Start to start plugins.
// 5. Call Close to close all plugins.
type PluginLoader struct {
state loaderState
plugins map[string]plugin.Plugin
Expand Down Expand Up @@ -96,6 +104,7 @@ func (loader *PluginLoader) transition(from, to loaderState) error {
return nil
}

// Load loads a plugin into the plugin loader.
func (loader *PluginLoader) Load(pl plugin.Plugin) error {
if err := loader.assertState(loaderLoading); err != nil {
return err
Expand All @@ -113,6 +122,7 @@ func (loader *PluginLoader) Load(pl plugin.Plugin) error {
return nil
}

// LoadDirectory loads a directory of plugins into the plugin loader.
func (loader *PluginLoader) LoadDirectory(pluginDir string) error {
if err := loader.assertState(loaderLoading); err != nil {
return err
Expand Down

0 comments on commit a9f7490

Please sign in to comment.