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, onError func(error)) error
- func (env *Environment) ActivePluginIds() (ids []string)
- func (env *Environment) ActivePlugins() []*model.BundleInfo
- func (env *Environment) DeactivatePlugin(id string) error
- func (env *Environment) Hooks() *MultiPluginHooks
- func (env *Environment) HooksForPlugin(id string) *SinglePluginHooks
- 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 MultiPluginHooks
- func (h *MultiPluginHooks) MessageHasBeenPosted(post *model.Post)
- func (h *MultiPluginHooks) MessageHasBeenUpdated(newPost, oldPost *model.Post)
- func (h *MultiPluginHooks) MessageWillBePosted(post *model.Post) (*model.Post, string)
- func (h *MultiPluginHooks) MessageWillBeUpdated(newPost, oldPost *model.Post) (*model.Post, string)
- func (h *MultiPluginHooks) OnConfigurationChange() []error
- func (h *MultiPluginHooks) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Option
- type SinglePluginHooks
- 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 system and 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, onError func(error)) 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() *MultiPluginHooks
func (*Environment) HooksForPlugin ¶
func (env *Environment) HooksForPlugin(id string) *SinglePluginHooks
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 MultiPluginHooks ¶
type MultiPluginHooks struct {
// contains filtered or unexported fields
}
func (*MultiPluginHooks) MessageHasBeenPosted ¶
func (h *MultiPluginHooks) MessageHasBeenPosted(post *model.Post)
func (*MultiPluginHooks) MessageHasBeenUpdated ¶
func (h *MultiPluginHooks) MessageHasBeenUpdated(newPost, oldPost *model.Post)
func (*MultiPluginHooks) MessageWillBePosted ¶
MessageWillBePosted invokes the MessageWillBePosted hook for all plugins. Ordering is not guaranteed and the next plugin will get the previous one's modifications. if a plugin rejects a post, the rest of the plugins will not know that an attempt was made. Returns the final result post, or nil if the post was rejected and a string with a reason for the user the message was rejected.
func (*MultiPluginHooks) MessageWillBeUpdated ¶
MessageWillBeUpdated invokes the MessageWillBeUpdated hook for all plugins. Ordering is not guaranteed and the next plugin will get the previous one's modifications. if a plugin rejects a post, the rest of the plugins will not know that an attempt was made. Returns the final result post, or nil if the post was rejected and a string with a reason for the user the message was rejected.
func (*MultiPluginHooks) OnConfigurationChange ¶
func (h *MultiPluginHooks) OnConfigurationChange() []error
OnConfigurationChange invokes the OnConfigurationChange hook for all plugins. Any errors encountered will be returned.
func (*MultiPluginHooks) ServeHTTP ¶
func (h *MultiPluginHooks) 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 SinglePluginHooks ¶
type SinglePluginHooks struct {
// contains filtered or unexported fields
}
func (*SinglePluginHooks) ExecuteCommand ¶
func (h *SinglePluginHooks) ExecuteCommand(args *model.CommandArgs) (resp *model.CommandResponse, appErr *model.AppError, err error)
ExecuteCommand invokes the ExecuteCommand hook for the plugin.
type SupervisorProviderFunc ¶
type SupervisorProviderFunc func(*model.BundleInfo) (plugin.Supervisor, error)