Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultManager = NewBaseManager()
DefaultManager is the default plugin manager
Functions ¶
This section is empty.
Types ¶
type BaseLoader ¶
type BaseLoader struct{}
BaseLoader is an default implementation of Loader interface
func (*BaseLoader) Load ¶
func (bl *BaseLoader) Load(plugin *spec.Plugin) (spec.PluginExecutor, error)
Load implements same method of Loader interface
type BaseManager ¶
type BaseManager struct {
// contains filtered or unexported fields
}
BaseManager is implemented as default plugin manager
func (*BaseManager) GetPlugin ¶
func (bm *BaseManager) GetPlugin(name string) (*spec.Plugin, spec.PluginExecutor, error)
GetPlugin implements the interface method
func (*BaseManager) LoadPlugin ¶
func (bm *BaseManager) LoadPlugin(name string) error
LoadPlugin implements the interface method
func (*BaseManager) LoadPlugins ¶
func (bm *BaseManager) LoadPlugins() error
LoadPlugins implements the interface method
func (*BaseManager) SetPluginBaseDir ¶
func (bm *BaseManager) SetPluginBaseDir(dir string) error
SetPluginBaseDir implements the interface method
func (*BaseManager) UnloadPlugin ¶
func (bm *BaseManager) UnloadPlugin(name string) error
UnloadPlugin implements the interface method
type BaseStore ¶
type BaseStore struct {
// contains filtered or unexported fields
}
BaseStore is the default implementation of Store interface
func (*BaseStore) Get ¶
func (bs *BaseStore) Get(name string) (*spec.PluginItem, bool)
Get is the implementation of same method in Store interface
func (*BaseStore) Put ¶
func (bs *BaseStore) Put(item *spec.PluginItem, forced bool)
Put is the implementation of same method in Store interface
type BaseValidatorChain ¶
type BaseValidatorChain struct {
// contains filtered or unexported fields
}
BaseValidatorChain build a validation pipeline with 'JSONFileValidator' and 'SpecValidator'.
func (*BaseValidatorChain) Validate ¶
func (bvc *BaseValidatorChain) Validate(params ...interface{}) (interface{}, error)
Validate is the implementation of Validator interface
type JSONFileValidator ¶
type JSONFileValidator struct{}
JSONFileValidator validates the existence of plugin.json.
func (*JSONFileValidator) Validate ¶
func (jfv *JSONFileValidator) Validate(params ...interface{}) (interface{}, error)
Validate is the implementation of Validator interface
type Loader ¶
type Loader interface { //Scan the plugin base dir and get the plugin candidates Scan(pluginBaseDir string) ([]string, error) //Parse the plugin metadata Parse(pluginPath string) (*spec.Plugin, error) //Load the plugin executor Load(plugin *spec.Plugin) (spec.PluginExecutor, error) }
Loader defines the plugin load flow
type LocalSourceValidator ¶
type LocalSourceValidator struct{}
LocalSourceValidator validate the local source
func (*LocalSourceValidator) Validate ¶
func (lsv *LocalSourceValidator) Validate(params ...interface{}) (interface{}, error)
Validate is the implementation of Validator interface
type Manager ¶
type Manager interface { //Set the base dir where to load plugins. //If the dir does not exist or it's not a dir //an error will be returned. SetPluginBaseDir(dir string) error //Load all the plugins from the base plugin dir. //Any issues happened, an error will be returned. LoadPlugins() error //Load plugin with the specified name. //If failed to load, an error will be returned. LoadPlugin(name string) error //Unload plugin with the specified name. //If failed to unload, an error will be returned. UnloadPlugin(name string) error //Get the plugin with the specified name. //If plugin is not existing, an error will be returned. GetPlugin(name string) (*spec.Plugin, spec.PluginExecutor, error) }
Manager defines the related operations of one plugin manager should support. Manager is used to load, organize and maintain the plugins.
type RemoteSourceValidator ¶
type RemoteSourceValidator struct{}
RemoteSourceValidator validates the remote source
func (*RemoteSourceValidator) Validate ¶
func (rsv *RemoteSourceValidator) Validate(params ...interface{}) (interface{}, error)
Validate is the implementation of Validator interface TODO:
type SpecValidator ¶
type SpecValidator struct{}
SpecValidator validates the plugin spec.
func (*SpecValidator) Validate ¶
func (sv *SpecValidator) Validate(params ...interface{}) (interface{}, error)
Validate is the implementation of Validator interface
type Store ¶
type Store interface { //The total count of current items in the store Size() uint //Append the plugin item to the store //If forced is set to be true, new plugin item will overwrite the existing one //Try best to append, ignore any errors Put(item *spec.PluginItem, forced bool) //Get the plugin item by name //If existing, return the item and set the bool flag to true Get(name string) (*spec.PluginItem, bool) //Remove the plugin out of the store and return the removed plugin item //If successfully removed, set the bool flag to true Remove(name string) (*spec.PluginItem, bool) }
Store defines how to maintain the loaded plugin
type Validator ¶
type Validator interface { //Do validation with the provided params. //If meet any issues, an error will be returned. //If succeed, output the result which depends on the implementations. Validate(params ...interface{}) (interface{}, error) }
Validator defines the behaviors of a plugin validator
func NewBaseValidatorChain ¶
NewBaseValidatorChain creates a validator chain