node

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Disabled = iota
	Enabled
)

Variables

View Source
var (
	DisabledPlugins = make(map[string]bool)
	EnabledPlugins  = make(map[string]bool)
)

Functions

func AddPlugin

func AddPlugin(plugin *Plugin)

func GetPluginIdentifier

func GetPluginIdentifier(name string) string

func GetPlugins

func GetPlugins() map[string]*Plugin

func IsSkipped

func IsSkipped(plugin *Plugin) bool

IsSkipped returns whether the plugin is loaded or skipped.

func Shutdown

func Shutdown()

Types

type AddEvent

type AddEvent struct {
	Name   string
	Status int
}

type Callback

type Callback = func(plugin *Plugin)

type ConfigureEvent

type ConfigureEvent struct {
	Plugin *Plugin
}

type InitEvent

type InitEvent struct {
	Plugin    *Plugin
	Container *dig.Container
}

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 (*Node) LoadedPlugins

func (node *Node) LoadedPlugins() []*Plugin

func (*Node) Run

func (node *Node) Run()

type NodeEvents

type NodeEvents struct {
	AddPlugin *event.Event1[*AddEvent]
}
var Events *NodeEvents

type NodeOption

type NodeOption func(*NodeOptions)

func Daemon

func Daemon(d daemon.Daemon) NodeOption

func Plugins

func Plugins(plugins ...*Plugin) NodeOption

type NodeOptions

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

type Plugin

type Plugin struct {
	Node   *Node
	Name   string
	Status int
	Events *PluginEvents

	WorkerPool *workerpool.WorkerPool
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin(name string, deps interface{}, status int, callbacks ...Callback) *Plugin

NewPlugin creates a new plugin with the given name, default status and callbacks. The last specified callback is the mandatory run callback, while all other callbacks are configure callbacks.

func (*Plugin) LogDebug

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

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

func (*Plugin) LogDebugf

func (p *Plugin) LogDebugf(format string, args ...interface{})

LogDebugf uses fmt.Sprintf to log a templated message.

func (*Plugin) LogError

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

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

func (*Plugin) LogErrorAndExit

func (p *Plugin) LogErrorAndExit(args ...interface{})

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

func (*Plugin) LogErrorf

func (p *Plugin) LogErrorf(format string, args ...interface{})

LogErrorf uses fmt.Sprintf to log a templated message.

func (*Plugin) LogErrorfAndExitf

func (p *Plugin) LogErrorfAndExitf(format string, args ...interface{})

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

func (*Plugin) LogFatalAndExit

func (p *Plugin) LogFatalAndExit(args ...interface{})

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

func (*Plugin) LogFatalfAndExitf

func (p *Plugin) LogFatalfAndExitf(format string, args ...interface{})

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

func (*Plugin) LogInfo

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

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

func (*Plugin) LogInfof

func (p *Plugin) LogInfof(format string, args ...interface{})

LogInfof uses fmt.Sprintf to log a templated message.

func (*Plugin) LogWarn

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

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

func (*Plugin) LogWarnf

func (p *Plugin) LogWarnf(format string, args ...interface{})

LogWarnf uses fmt.Sprintf to log a templated message.

func (*Plugin) Logger

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

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

func (*Plugin) Panic

func (p *Plugin) Panic(args ...interface{})

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

func (*Plugin) Panicf

func (p *Plugin) Panicf(template string, args ...interface{})

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

type PluginEvents

type PluginEvents struct {
	Init      *event.Event1[*InitEvent]
	Configure *event.Event1[*ConfigureEvent]
	Run       *event.Event1[*RunEvent]
}

type RunEvent

type RunEvent struct {
	Plugin *Plugin
}

Jump to

Keyboard shortcuts

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