node

package
Version: v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

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.

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
	// contains filtered or unexported fields
}

InitConfig describes the result of a node initialization.

func (*InitConfig) ForceDisablePluggable added in v1.0.5

func (ic *InitConfig) ForceDisablePluggable(identifier string)

ForceDisablePluggable is used to force disable pluggables before the provide stage.

type InitConfigParsFunc added in v1.0.5

type InitConfigParsFunc func(c *dig.Container)

InitConfigParsFunc gets called with a dig.Container.

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 {
	// 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) LogDebug added in v1.0.5

func (n *Node) LogDebug(args ...interface{})

LogDebug uses fmt.Sprint to construct and log a message.

func (*Node) LogDebugf added in v1.0.5

func (n *Node) LogDebugf(template string, args ...interface{})

LogDebugf uses fmt.Sprintf to log a templated message.

func (*Node) LogError added in v1.0.5

func (n *Node) LogError(args ...interface{})

LogError uses fmt.Sprint to construct and log a message.

func (*Node) LogErrorf added in v1.0.5

func (n *Node) LogErrorf(template string, args ...interface{})

LogErrorf uses fmt.Sprintf to log a templated message.

func (*Node) LogFatal added in v1.0.5

func (n *Node) LogFatal(args ...interface{})

LogFatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func (*Node) LogFatalf added in v1.0.5

func (n *Node) LogFatalf(template string, args ...interface{})

LogFatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func (*Node) LogInfo added in v1.0.5

func (n *Node) LogInfo(args ...interface{})

LogInfo uses fmt.Sprint to construct and log a message.

func (*Node) LogInfof added in v1.0.5

func (n *Node) LogInfof(template string, args ...interface{})

LogInfof uses fmt.Sprintf to log a templated message.

func (*Node) LogPanic added in v1.1.0

func (n *Node) LogPanic(args ...interface{})

LogPanic uses fmt.Sprint to construct and log a message, then panics.

func (*Node) LogPanicf added in v1.1.0

func (n *Node) LogPanicf(template string, args ...interface{})

LogPanicf uses fmt.Sprintf to log a templated message, then panics.

func (*Node) LogWarn added in v1.0.5

func (n *Node) LogWarn(args ...interface{})

LogWarn uses fmt.Sprint to construct and log a message.

func (*Node) LogWarnf added in v1.0.5

func (n *Node) LogWarnf(template string, args ...interface{})

LogWarnf uses fmt.Sprintf to log a templated message.

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{}
	// InitConfigPars gets called in the init stage of node initialization.
	// This can be used to provide config parameters even if the pluggable is disabled.
	InitConfigPars InitConfigParsFunc
	// PreProvide gets called before the provide stage of node initialization.
	// This can be used to force disable other pluggables before they get initialized.
	PreProvide PreProvideFunc
	// Provide gets called in the provide stage of node initialization (enabled pluggables only).
	Provide ProvideFunc
	// Configure gets called in the configure stage of node initialization (enabled pluggables only).
	Configure Callback
	// Run gets called in the run stage of node initialization (enabled pluggables only).
	Run Callback
	// contains filtered or unexported fields
}

Pluggable is something which extends the Node's capabilities.

func (*Pluggable) Daemon added in v1.0.5

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

func (*Pluggable) Identifier added in v1.0.5

func (p *Pluggable) Identifier() string

func (*Pluggable) LogDebug added in v1.0.5

func (p *Pluggable) LogDebug(args ...interface{})

LogDebug uses fmt.Sprint to construct and log a message.

func (*Pluggable) LogDebugf added in v1.0.5

func (p *Pluggable) LogDebugf(template string, args ...interface{})

LogDebugf uses fmt.Sprintf to log a templated message.

func (*Pluggable) LogError added in v1.0.5

func (p *Pluggable) LogError(args ...interface{})

LogError uses fmt.Sprint to construct and log a message.

func (*Pluggable) LogErrorf added in v1.0.5

func (p *Pluggable) LogErrorf(template string, args ...interface{})

LogErrorf uses fmt.Sprintf to log a templated message.

func (*Pluggable) LogFatal added in v1.0.5

func (p *Pluggable) LogFatal(args ...interface{})

LogFatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func (*Pluggable) LogFatalf added in v1.0.5

func (p *Pluggable) LogFatalf(template string, args ...interface{})

LogFatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func (*Pluggable) LogInfo added in v1.0.5

func (p *Pluggable) LogInfo(args ...interface{})

LogInfo uses fmt.Sprint to construct and log a message.

func (*Pluggable) LogInfof added in v1.0.5

func (p *Pluggable) LogInfof(template string, args ...interface{})

LogInfof uses fmt.Sprintf to log a templated message.

func (*Pluggable) LogPanic added in v1.1.0

func (p *Pluggable) LogPanic(args ...interface{})

LogPanic uses fmt.Sprint to construct and log a message, then panics.

func (*Pluggable) LogPanicf added in v1.1.0

func (p *Pluggable) LogPanicf(template string, args ...interface{})

LogPanicf uses fmt.Sprintf to log a templated message, then panics.

func (*Pluggable) LogWarn added in v1.0.5

func (p *Pluggable) LogWarn(args ...interface{})

LogWarn uses fmt.Sprint to construct and log a message.

func (*Pluggable) LogWarnf added in v1.0.5

func (p *Pluggable) LogWarnf(template string, args ...interface{})

LogWarnf uses fmt.Sprintf to log a templated message.

func (*Pluggable) Logger added in v1.0.5

func (p *Pluggable) Logger() *logger.Logger

Logger instantiates and returns a logger with the name of the plugin.

type Plugin

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

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 PluginStatus added in v1.0.5

type PluginStatus int
const (
	StatusDisabled PluginStatus = iota
	StatusEnabled
)

type PreProvideFunc added in v1.0.5

type PreProvideFunc func(c *dig.Container, configs map[string]*configuration.Configuration, initConf *InitConfig)

PreProvideFunc gets called with a dig.Container, the configs the InitPlugin brings to the node and the InitConfig.

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