Update plugin load and snapshot service

Allow plugins to be mapped and returned by their ID.
Add skip plugin to allow plugins to decide whether they should
be loaded.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2017-06-27 16:55:50 -07:00
parent 5b105f86ce
commit 3db8adc5d7
11 changed files with 82 additions and 47 deletions

View File

@@ -1,18 +1,31 @@
package plugin
import (
"errors"
"fmt"
"sync"
"github.com/pkg/errors"
"google.golang.org/grpc"
)
var (
ErrNoPluginType = errors.New("plugin: no type")
ErrNoPluginID = errors.New("plugin: no id")
// SkipPlugin is used when a plugin is not initialized and should not be loaded,
// this allows the plugin loader differentiate between a plugin which is configured
// not to load and one that fails to load.
SkipPlugin = errors.New("skip plugin")
)
// IsSkipPlugin returns true if the error is skipping the plugin
func IsSkipPlugin(err error) bool {
if errors.Cause(err) == SkipPlugin {
return true
}
return false
}
type PluginType string
const (