plugins

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePlugin

type BasePlugin struct {
	Context context.Context
	Cancel  context.CancelFunc
	Name    PluginName
	Version string
	Config  any
	Event   *event.Event
	State   PluginState
	Log     *logrus.Entry
	Mu      *sync.RWMutex
	Stop    chan error
	Pool    *ants.Pool
}

func (*BasePlugin) BaseInit

func (b *BasePlugin) BaseInit() error

func (*BasePlugin) GetName

func (b *BasePlugin) GetName() PluginName

func (*BasePlugin) GetState

func (b *BasePlugin) GetState() PluginState

func (*BasePlugin) GetVersion

func (b *BasePlugin) GetVersion() string

func (*BasePlugin) ParseConfig

func (b *BasePlugin) ParseConfig(cfg any) error

func (*BasePlugin) RecvEvent

func (b *BasePlugin) RecvEvent() chan *event.Message

func (*BasePlugin) SendEvent

func (b *BasePlugin) SendEvent(to PluginName, action string, data any) error

func (*BasePlugin) SetConfig

func (b *BasePlugin) SetConfig(cfg any)

type Plugin

type Plugin interface {
	Init() error             // init the plugin
	Run()                    // run the plugin
	Stop()                   // stop the plugin
	Metrics() *PluginMetrics // stats the plugin
	Health() PluginState     // get the health of the plugin
	RefreshConfig(cfg any)   // refresh the config of the plugin
}

type PluginMetrics

type PluginMetrics struct {
}

type PluginName

type PluginName string

const (

PluginHealthGreen  PluginHealth = "green"
PluginHealthYellow PluginHealth = "yellow"
PluginHealthRed    PluginHealth = "red"

)

type PluginState

type PluginState string
const (
	PluginStateCreate  PluginState = "create"
	PluginStateInit    PluginState = "init"
	PluginStateRunning PluginState = "running"
	PluginStateStopped PluginState = "stopped"
	PluginStatePaused  PluginState = "paused"
)

Jump to

Keyboard shortcuts

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