Documentation ¶
Index ¶
- func Main(pluginName string)
- type Initializer
- type InitializerFunc
- type Manager
- func (m *Manager) Configure() []error
- func (m *Manager) Loaded() []string
- func (m *Manager) Lookup(name string) (Plugin, error)
- func (m *Manager) OnPluginInit(h PluginInitHandler)
- func (m *Manager) OnShutdown(h ShutdownHandler)
- func (m *Manager) Register(initfn Initializer)
- func (m *Manager) RegisterFunc(initfn func(m *Manager) (Plugin, error))
- func (m *Manager) Shutdown()
- type Plugin
- type PluginInitHandler
- type ShutdownHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Initializer ¶
type Initializer interface { // Initialize creates the corresponding Plugin for this Initializer. Initialize(*Manager) (Plugin, error) }
An Initializer is a type that can create a Plugin implementation.
func InitializeFromFile ¶
func InitializeFromFile(p string) Initializer
InitializeFromFile returns an Initializer that will attempt to load the specified plugin shared library from the filesystem. Shared library plugins must be built as a `main` package and must have an "Initialize" function defined at the package level. The "Initialize" function must be compatible with the Initialize method on the Initializer interface. That is, it must have the signature:
func Initialize(*Manager) (Plugin, error)
type InitializerFunc ¶
An InitializerFunc is a function that implements Initializer.
func (InitializerFunc) Initialize ¶
func (f InitializerFunc) Initialize(m *Manager) (Plugin, error)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager controls the loading and configuration of plugins.
func NewManager ¶
func (*Manager) Configure ¶
Configure attempts to load and configure all registered plugins. An error will be returned for each failed initialization.
func (*Manager) OnPluginInit ¶
func (m *Manager) OnPluginInit(h PluginInitHandler)
OnPluginInit adds the given PluginInitHandler to be called when a plugin is initialized.
func (*Manager) OnShutdown ¶
func (m *Manager) OnShutdown(h ShutdownHandler)
OnShutdown adds the given ShutdownHandler to be called when the appliation is shutting down.
func (*Manager) Register ¶
func (m *Manager) Register(initfn Initializer)
Register adds a plugin Initializer to the Manager. Invoke all the registered Initializers by calling Configure on the Manager.
func (*Manager) RegisterFunc ¶
RegisterFunc is a shorthand method to register an InitializerFunc without extra type assertions.
type Plugin ¶
type Plugin interface { // Name returns the unique name for the Plugin. Name() string }
A Plugin is the basic interface that all squircy3 plugins must implement.
type PluginInitHandler ¶ added in v0.10.0
type PluginInitHandler interface { // HandlePluginInit is called after each other Plugin is initialized. // Plugin initialization occurs when the Configure method is called on // a plugin.Manager. HandlePluginInit(Plugin) }
PluginInitHandler is implemented by types that want to be notified when another plugin is initialized.
type ShutdownHandler ¶
type ShutdownHandler interface { // HandleShutdown is called when the application begins shutting down. // All ShutdownHandlers are invoked concurrently, but each has a limited // amount of time to gracefully clean up before the application forcefully // exits. HandleShutdown() Name() string }
ShutdownHandler is implemented by types that want to perform some action when the application is shutting down.