node

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 9 Imported by: 59

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 Start

func Start(optionalOptions ...NodeOption) *Node

func (*Node) Run

func (node *Node) Run()

func (*Node) Start

func (node *Node) Start()

type NodeEvents

type NodeEvents struct {
	AddPlugin *event.Event[*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
	// 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) LogErrorfAndExit

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

LogErrorfAndExit 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) LogFatalfAndExit

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

LogFatalfAndExit 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.Event[*InitEvent]
	Configure *event.Event[*ConfigureEvent]
	Run       *event.Event[*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