plugins

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(cfg *config.Config) error

Initialize builds all plugins defined in config file.

func RegisterPlugin

func RegisterPlugin(pt config.PluginType, name string, builder Builder)

RegisterPlugin register a plugin builder that will be called to create a new plugin instant when supernode starts.

func SetManager

func SetManager(m Manager)

SetManager sets a Manager implementation instead of the default one.

Types

type Builder

type Builder func(conf string) (Plugin, error)

Builder is a function that creates a new plugin instant with the giving conf.

type Manager

type Manager interface {
	// GetBuilder adds a Builder object with the giving plugin type and name.
	AddBuilder(pt config.PluginType, name string, b Builder)

	// GetBuilder returns a Builder object with the giving plugin type and name.
	GetBuilder(pt config.PluginType, name string) Builder

	// DeleteBuilder deletes a builder with the giving plugin type and name.
	DeleteBuilder(pt config.PluginType, name string)

	// AddPlugin adds a plugin into this manager.
	AddPlugin(p Plugin)

	// GetPlugin returns a plugin with the giving plugin type and name.
	GetPlugin(pt config.PluginType, name string) Plugin

	// DeletePlugin deletes a plugin with the giving plugin type and name.
	DeletePlugin(pt config.PluginType, name string)
}

Manager manages all plugin builders and plugin instants.

func NewManager

func NewManager() Manager

NewManager creates a default plugin manager instant.

type Plugin

type Plugin interface {
	// Type returns the type of this plugin.
	Type() config.PluginType

	// Name returns the name of this plugin.
	Name() string
}

Plugin defines methods that plugins need to implement.

func GetPlugin

func GetPlugin(pt config.PluginType, name string) Plugin

GetPlugin returns a plugin instant with the giving plugin type and name.

type Repository

type Repository interface {
	// Add adds a data to this repository.
	Add(pt config.PluginType, name string, data interface{})

	// Get gets a data with the giving type and name from this
	// repository.
	Get(pt config.PluginType, name string) interface{}

	// Delete deletes a data with the giving type and name from
	// this repository.
	Delete(pt config.PluginType, name string)
}

Repository stores data related to plugin.

func NewRepository

func NewRepository() Repository

NewRepository creates a default repository instant.

Jump to

Keyboard shortcuts

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