pluginenv

package
v4.10.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2018 License: AGPL-3.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package pluginenv provides high level functionality for discovering and launching plugins.

Index

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 APIProviderFunc

type APIProviderFunc func(*model.Manifest) (plugin.API, error)

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() *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) 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

func SearchPath(path string) Option

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

func WebappPath(path string) Option

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL