Documentation ¶
Overview ¶
Package plugin implements a general plugin factory system which provides plugin registration and loading. It is mainly used when certain plugins must be loaded by configuration. This system is not supposed to register plugins that do not rely on configuration like codec. Instead, plugins that do not rely on configuration should be registered by calling methods in certain packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // SetupTimeout is the timeout for initialization of each plugin. // Modify it if some plugins' initialization does take a long time. SetupTimeout = 10 * time.Second // MaxPluginSize is the max number of plugins. MaxPluginSize = 1000 )
var ( Connector = "connector" Registry = "registry" Protocol = "protocol" )
indicates all plugin type
var ( NacosRegistry = "nacos" ETCDRegistry = "etcd" )
indicates registry name list
var Name = "name"
name for every plugin
var (
Standalone = "standalone"
)
indicates connector name list
Functions ¶
func Register ¶
Register registers a plugin factory. Name of the plugin should be specified. It is supported to register instances which are the same implementation of plugin Plugin but use different configuration.
func SetActivePlugin ¶
Types ¶
type Config ¶
Config is the configuration of all plugins. plugin type => { plugin name => plugin config }
type Decoder ¶
type Decoder interface {
Decode(cfg interface{}) error // the input param is the custom configuration of the plugin
}
Decoder is the interface used to decode plugin configuration.
type Plugin ¶
type Plugin interface { // Type returns type of the plugin, i.e. selector, log, config, tracing. Type() string // Setup loads plugin by configuration. // The data structure of the configuration of the plugin needs to be defined in advance。 Setup(name string, dec Decoder) error }
Plugin is the interface for plugin factory abstraction. Custom Plugins need to implement this interface to be registered as a plugin with certain type.
type YamlNodeDecoder ¶
YamlNodeDecoder is a decoder for a yaml.Node of the yaml config file.
func (*YamlNodeDecoder) Decode ¶
func (d *YamlNodeDecoder) Decode(cfg interface{}) error
Decode decodes a yaml.Node of the yaml config file.
Directories ¶
Path | Synopsis |
---|---|
rocketmq/mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
database
|
|
nacos/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |