Documentation ¶
Overview ¶
Package pluginenv provides high level functionality for discovering and launching plugins.
Index ¶
- func DefaultSupervisorProvider(bundle *model.BundleInfo) (plugin.Supervisor, error)
- func ScanSearchPath(path string) ([]*model.BundleInfo, error)
- type APIProviderFunc
- type ActivePlugin
- type Environment
- func (env *Environment) ActivatePlugin(id string) error
- func (env *Environment) ActivePluginIds() (ids []string)
- func (env *Environment) ActivePlugins() []*model.BundleInfo
- func (env *Environment) DeactivatePlugin(id string) error
- func (env *Environment) Hooks() *EnvironmentHooks
- func (env *Environment) IsPluginActive(pluginId string) bool
- func (env *Environment) Plugins() ([]*model.BundleInfo, error)
- func (env *Environment) SearchPath() string
- func (env *Environment) Shutdown() (errs []error)
- func (env *Environment) WebappPath() string
- type EnvironmentHooks
- type Option
- type SupervisorProviderFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSupervisorProvider ¶
func DefaultSupervisorProvider(bundle *model.BundleInfo) (plugin.Supervisor, error)
DefaultSupervisorProvider chooses a supervisor based on the plugin's manifest contents. E.g. if the manifest specifies a backend executable, it will be given an rpcplugin.Supervisor.
func ScanSearchPath ¶
func ScanSearchPath(path string) ([]*model.BundleInfo, error)
Performs a full scan of the given path.
This function will return info for all subdirectories that appear to be plugins (i.e. all subdirectories containing plugin manifest files, regardless of whether they could actually be parsed).
Plugins are found non-recursively and paths beginning with a dot are always ignored.
Types ¶
type ActivePlugin ¶
type ActivePlugin struct { BundleInfo *model.BundleInfo Supervisor plugin.Supervisor }
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment represents an environment that plugins are discovered and launched in.
func New ¶
func New(options ...Option) (*Environment, error)
Creates a new environment. At a minimum, the APIProvider and SearchPath options are required.
func (*Environment) ActivatePlugin ¶
func (env *Environment) ActivatePlugin(id string) error
Activates the plugin with the given id.
func (*Environment) ActivePluginIds ¶
func (env *Environment) ActivePluginIds() (ids []string)
Returns the ids of the currently active plugins.
func (*Environment) ActivePlugins ¶
func (env *Environment) ActivePlugins() []*model.BundleInfo
Returns a list of all currently active plugins within the environment.
func (*Environment) DeactivatePlugin ¶
func (env *Environment) DeactivatePlugin(id string) error
Deactivates the plugin with the given id.
func (*Environment) Hooks ¶
func (env *Environment) Hooks() *EnvironmentHooks
func (*Environment) IsPluginActive ¶
func (env *Environment) IsPluginActive(pluginId string) bool
Returns true if the plugin is active, false otherwise.
func (*Environment) Plugins ¶
func (env *Environment) Plugins() ([]*model.BundleInfo, error)
Returns a list of all plugins found within the environment.
func (*Environment) SearchPath ¶
func (env *Environment) SearchPath() string
Returns the configured search path.
func (*Environment) Shutdown ¶
func (env *Environment) Shutdown() (errs []error)
Deactivates all plugins and gracefully shuts down the environment.
func (*Environment) WebappPath ¶
func (env *Environment) WebappPath() string
Returns the configured webapp path.
type EnvironmentHooks ¶
type EnvironmentHooks struct {
// contains filtered or unexported fields
}
func (*EnvironmentHooks) OnConfigurationChange ¶
func (h *EnvironmentHooks) OnConfigurationChange() (errs []error)
OnConfigurationChange invokes the OnConfigurationChange hook for all plugins. Any errors encountered will be returned.
func (*EnvironmentHooks) ServeHTTP ¶
func (h *EnvironmentHooks) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP invokes the ServeHTTP hook for the plugin identified by the request or responds with a 404 not found.
It expects the request's context to have a plugin_id set.
type Option ¶
type Option func(*Environment)
func APIProvider ¶
func APIProvider(provider APIProviderFunc) Option
APIProvider specifies a function that provides an API implementation to each plugin.
func SearchPath ¶
SearchPath specifies a directory that contains the plugins to launch.
func SupervisorProvider ¶
func SupervisorProvider(provider SupervisorProviderFunc) Option
SupervisorProvider specifies a function that provides a Supervisor implementation to each plugin. If unspecified, DefaultSupervisorProvider is used.
func WebappPath ¶
WebappPath specifies the static directory serving the webapp.
type SupervisorProviderFunc ¶
type SupervisorProviderFunc func(*model.BundleInfo) (plugin.Supervisor, error)