Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPlugin ¶
func RegisterPlugin(plugin interface{})
Types ¶
type Plugin ¶
type Plugin interface { }
Interface required to be considered a plugin The only methods defined are those that make it possible for GoPlugin to register and understand how to treat plugins.
So far this just includes the Type() method which informs a PluginManager what kind of plugin has been loaded
type PluginFactory ¶
type PluginFactory struct {
TypeFn func() Type
}
A helper struct to be embedded to more easily create plugin Factories
type PluginInterfaceConfig ¶
type PluginInterfaceConfig struct { // An easily used indentifier to match // plugins to defined interfaces Identifier Type // The defined interface which plugins // must implement Interface interface{} // A struct to act as a factory for creating // new instances of a loaded plugin of a certain // type Factory interface{} // contains filtered or unexported fields }
Configuration for a PluginInterface definition
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
Manages the definitions, loadings, initializations, and access of plugins
func NewPluginManager ¶
func NewPluginManager(cfg PluginManagerConfig) (*PluginManager, error)
Creata a new instance of the plugin manager with a given PluginMangerConfig
func (*PluginManager) Init ¶
func (pm *PluginManager) Init()
Initialze the PluginManager once all the PluginInterfaces have been defined, and load the plugins
func (*PluginManager) LoadPlugins ¶
func (pm *PluginManager) LoadPlugins() error
Load all the plugins that can be found in configured plugin Dir
func (PluginManager) Plugin ¶
func (pm PluginManager) Plugin(name string) interface{}
Return an individual plugin instance by name
func (PluginManager) Plugins ¶
func (pm PluginManager) Plugins(t Type) []interface{}
Return an array of plugins of the given Type t
func (*PluginManager) RegisterInterface ¶
func (pm *PluginManager) RegisterInterface(cfg PluginInterfaceConfig) error
Register a plugin to be used by your application. Requires a type to identify plugins by, and interface and factory to generate plugins of that interface with
type PluginManagerConfig ¶
type PluginManagerConfig struct { // Directory to load plugins from Dir string }
Configuration for PluginManagers
Directories ¶
Path | Synopsis |
---|---|
example
|
|
plugin_add
* This file was AUTO GENERATED by GoPlugin * to create an externally available interface * for the defined plugins * * The interface relies on C and CGO to 'export' * user defined plugins via a simple C-Style * interface * * To read more visit: * www.goplugin.org/how-it-works#external-plugin
|
* This file was AUTO GENERATED by GoPlugin * to create an externally available interface * for the defined plugins * * The interface relies on C and CGO to 'export' * user defined plugins via a simple C-Style * interface * * To read more visit: * www.goplugin.org/how-it-works#external-plugin |