pluginenv

package
v4.3.0-rc4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: AGPL-3.0, Apache-2.0 Imports: 9 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 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() *EnvironmentHooks

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

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 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