plugins

package
v0.0.0-...-dffe54d Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	Start PluginStartFunc
	Stop  PluginStopFunc
	Call  PluginCallFunc

	Name     string
	Metadata types.PluginMetadata
}

Plugin type

func NewPlugin

func NewPlugin(ctx context.Context, log *zap.Logger, filePath string, pluginConfig *PluginConfig) (*Plugin, error)

func (*Plugin) RunCall

func (p *Plugin) RunCall(ctx context.Context, log *zap.Logger, payload *types.Payload) ([]*types.PowerlineReturn, error)

func (*Plugin) RunStart

func (p *Plugin) RunStart(ctx context.Context, log *zap.Logger) (*types.PluginStartData, error)

func (*Plugin) RunStop

func (p *Plugin) RunStop(ctx context.Context, log *zap.Logger) error

type PluginCallFunc

type PluginCallFunc func(context.Context, *zap.Logger, *types.Payload) ([]*types.PowerlineReturn, error)

Called when we need to render a segment effectively

type PluginConfig

type PluginConfig struct {
	UserHome     string
	GowerlineDir string
	PluginName   string
	// BoltDB is used as a K/V cache for data for plugins that
	// would need them. Careful though as it is not thread safe.
	BoltDB *bolt.DB
	// StorageDir is the directory that would hold plugin specific data
	// such as caches and what not. It will also hold the bolt databases
	// that comes with all plugins by default.
	StorageDir string
	// Config is a yaml node containing the configuration that
	// is specific to the plugin
	Config yaml.Node
}

PluginConfig will be passed down to plugins

type PluginStartFunc

type PluginStartFunc func(context.Context, *zap.Logger) (*types.PluginStartData, error)

Called when a plugin starts, returns data such as the plugin name

type PluginStopFunc

type PluginStopFunc func(context.Context, *zap.Logger) error

Called when a plugin stops, must wait before effectively stopping

Jump to

Keyboard shortcuts

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