plugin

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const REGISTRABLE_VAR = "Registrable"

REGISTRABLE_VAR is the name to lookup after loading the plugin for the module registering

Variables

This section is empty.

Functions

func Load

func Load(cfg config.Plugin, reg *Register) (int, error)

Load loads all the plugins in pluginFolder with pattern in its filename. It returns the number of plugins loaded and an error if something goes wrong.

func Scan added in v1.0.0

func Scan(folder, pattern string) ([]string, error)

Types

type Plugin

type Plugin interface {
	Lookup(name string) (plugin.Symbol, error)
}

Plugin is the interface of the loaded plugins

type Register

type Register struct {
	Decoder  *encoding.DecoderRegister
	SD       *sd.Register
	External *register.Namespaced
}

Register contains all the registers required by the framework and the external modules

func NewRegister

func NewRegister() *Register

NewRegister returns a new register to be used by the plugin loader

func (*Register) Register

func (r *Register) Register(p Plugin) error

Register registers the received plugin in the proper internal registers

Example (Ok)
reg := NewRegister()
p := dummyPlugin{
	content: plugin.Symbol(registrableDummy(1)),
}
if err := reg.Register(p); err != nil {
	fmt.Println(err.Error())
}
Output:

registrable 1 from plugin samplePluginName is registering its decoder components
registrable 1 from plugin samplePluginName is registering its components depending on external modules
Example (UnknownInterface)
reg := NewRegister()
p := dummyPlugin{
	content: plugin.Symbol(1),
}
if err := reg.Register(p); err != nil {
	fmt.Println(err.Error())
}
Output:

unknown registrable interface

type RegistrableDecoder

type RegistrableDecoder interface {
	RegisterDecoder(func(name string, dec func(bool) func(io.Reader, *map[string]interface{}) error) error) error
}

RegistrableDecoder defines the interface the encoding plugins should implement in order to be able to register themselves

type RegistrableExternal

type RegistrableExternal interface {
	RegisterExternal(func(namespace, name string, v interface{})) error
}

RegistrableExternal defines the interface the external plugins should implement in order to be able to register themselves

Directories

Path Synopsis
tests
app

Jump to

Keyboard shortcuts

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