node

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Disabled = iota
	Enabled
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback func()

Callback is a function called without any arguments.

type CorePlugin

type CorePlugin struct {
	Pluggable
}

CorePlugin is a plugin essential for node operation. It can not be disabled.

func (*CorePlugin) Daemon

func (c *CorePlugin) Daemon() daemon.Daemon

type CorePluginForEachFunc

type CorePluginForEachFunc func(corePlugin *CorePlugin) bool

CorePluginForEachFunc is used in ForEachCorePlugin. Returning false indicates to stop looping.

type InitConfig

type InitConfig struct {
	EnabledPlugins  []string
	DisabledPlugins []string
}

InitConfig describes the result of a node initialization.

type InitFunc

type InitFunc func(params map[string][]*flag.FlagSet, maskedKeys []string) (*InitConfig, error)

InitFunc gets called as the initialization function of the node.

type InitPlugin

type InitPlugin struct {
	Pluggable
	// Init gets called in the initialization stage of the node.
	Init InitFunc
	// The configs this InitPlugin brings to the node.
	Configs map[string]*configuration.Configuration
}

InitPlugin is the module initializing configuration of the node. A Node can only have one of such modules.

type Node

type Node struct {
	Logger *logger.Logger
	// contains filtered or unexported fields
}

func New

func New(optionalOptions ...NodeOption) *Node

func Run

func Run(optionalOptions ...NodeOption) *Node

func Start

func Start(optionalOptions ...NodeOption) *Node

func (*Node) Daemon

func (n *Node) Daemon() daemon.Daemon

func (*Node) ForEachCorePlugin

func (n *Node) ForEachCorePlugin(f CorePluginForEachFunc)

ForEachCorePlugin calls the given CorePluginForEachFunc on each loaded core plugins.

func (*Node) ForEachPlugin

func (n *Node) ForEachPlugin(f PluginForEachFunc)

ForEachPlugin calls the given PluginForEachFunc on each loaded plugin.

func (*Node) IsSkipped

func (n *Node) IsSkipped(plugin *Plugin) bool

IsSkipped returns whether the plugin is loaded or skipped.

func (*Node) Run

func (n *Node) Run()

func (*Node) Shutdown

func (n *Node) Shutdown()

func (*Node) Start

func (n *Node) Start()

type NodeOption

type NodeOption func(opts *NodeOptions)

NodeOption is a function setting a NodeOptions option.

func WithCorePlugins

func WithCorePlugins(corePlugins ...*CorePlugin) NodeOption

WithCorePlugins sets the core plugins.

func WithDaemon

func WithDaemon(daemon daemon.Daemon) NodeOption

WithDaemon sets the used daemon.

func WithInitPlugin

func WithInitPlugin(initPlugin *InitPlugin) NodeOption

WithInitPlugin sets the init plugin.

func WithPlugins

func WithPlugins(plugins ...*Plugin) NodeOption

WithPlugins sets the plugins.

type NodeOptions

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

NodeOptions defines options for a Node.

type Pluggable

type Pluggable struct {
	// A reference to the Node instance.
	Node *Node
	// The name of the plugin.
	Name string
	// The config parameters for this plugin.
	Params *PluginParams
	// The function to call to initialize the plugin dependencies.
	DepsFunc interface{}
	// Provide gets called in the provide stage of node initialization.
	Provide ProvideFunc
	// Configure gets called in the configure stage of node initialization.
	Configure Callback
	// Run gets called in the run stage of node initialization.
	Run Callback
}

Pluggable is something which extends the Node's capabilities.

type Plugin

type Plugin struct {
	Pluggable
	// The status of the plugin.
	Status int
}

func (*Plugin) Daemon

func (p *Plugin) Daemon() daemon.Daemon

func (*Plugin) GetIdentifier

func (p *Plugin) GetIdentifier() string

type PluginForEachFunc

type PluginForEachFunc func(plugin *Plugin) bool

PluginForEachFunc is used in ForEachPlugin. Returning false indicates to stop looping.

type PluginParams

type PluginParams struct {
	// The parameters of the plugin under for the defined configuration.
	Params map[string]*flag.FlagSet
	// The configuration values to mask.
	Masked []string
}

PluginParams defines the parameters configuration of a plugin.

type ProvideFunc

type ProvideFunc func(c *dig.Container)

ProvideFunc gets called with a dig.Container.

Jump to

Keyboard shortcuts

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