plugins

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 8 Imported by: 2

README

Plugins

Plugins is a plugin helper controller

Documentation

Index

Constants

View Source
const (
	// ErrExpectedEndParen is returned when an ending parenthesis is missing
	ErrExpectedEndParen = errors.Error("expected ending parenthesis")
	// ErrInvalidDir is returned when a directory is empty
	ErrInvalidDir = errors.Error("invalid directory, cannot be empty")
	// ErrPluginKeyExists is returned when a plugin cannot be added because it already exists
	ErrPluginKeyExists = errors.Error("plugin cannot be added, key already exists")
	// ErrPluginNotLoaded is returned when a plugin namespace is provided that has not been loaded
	ErrPluginNotLoaded = errors.Error("plugin with that key has not been loaded")
	// ErrNotAddressable is returned when a non-addressable value is provided
	ErrNotAddressable = errors.Error("provided backend must be addressable")
)

Variables

This section is empty.

Functions

func Backend added in v0.6.0

func Backend(key string, backend interface{}) error

Backend will associated the backend of the requested key

func Loaded added in v0.6.0

func Loaded() map[string]Plugin

Loaded will return the plugins which have been loaded

func ParseKey

func ParseKey(key string) (newKey, alias string)

ParseKey returns stripped gitUrl and plugin alias

func Register added in v0.5.0

func Register(key string, pi Plugin) error

Register will register a plugin with a given key

Types

type BasePlugin added in v0.5.0

type BasePlugin struct{}

func (*BasePlugin) Backend added in v0.5.0

func (b *BasePlugin) Backend() interface{}

func (*BasePlugin) Close added in v0.5.0

func (b *BasePlugin) Close() error

func (*BasePlugin) Init added in v0.5.0

func (b *BasePlugin) Init(env map[string]string) error

func (*BasePlugin) Load added in v0.5.0

func (b *BasePlugin) Load() error

type Plugin

type Plugin interface {
	Init(env map[string]string) error
	Load() error
	Backend() interface{}
	Close() error
}

func Get added in v0.5.0

func Get(key string) (Plugin, error)

Get will retrieve a plugin with a given key

type Plugins

type Plugins struct {
	// contains filtered or unexported fields
}

Plugins manages loaded plugins

func (*Plugins) Backend

func (p *Plugins) Backend(key string, backend interface{}) (err error)

Backend will associated the backend of the requested key

func (*Plugins) Close

func (p *Plugins) Close() (err error)

Close will close plugins

func (*Plugins) Get

func (p *Plugins) Get(key string) (pi Plugin, err error)

Get will get a plugin by it's key

func (*Plugins) Loaded added in v0.6.0

func (p *Plugins) Loaded() (pm map[string]Plugin)

func (*Plugins) Register added in v0.5.0

func (p *Plugins) Register(key string, pi Plugin) (err error)

New will load a new plugin by plugin key The following formats are accepted as keys:

  • path/to/file/plugin.so
  • github.com/username/repository/pluginDir

func (*Plugins) Test

func (p *Plugins) Test() (err error)

Test will test all of the plugins

func (*Plugins) TestAsync

func (p *Plugins) TestAsync(q *queue.Queue) (err error)

TestAsync will test all of the plugins asynchronously

Jump to

Keyboard shortcuts

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