plugin

package
v0.0.0-...-2056ee4 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtocolVersion    uint = 1
	MagicCookieKey          = "REGINALD_PLUGIN"
	MagicCookieCommand      = "command"
	MagicCookieTask         = "task"
)

Variables

View Source
var (
	CmdHandshakeConfig = plugin.HandshakeConfig{
		ProtocolVersion:  ProtocolVersion,
		MagicCookieKey:   MagicCookieKey,
		MagicCookieValue: MagicCookieCommand,
	}
	TaskHandshakeConfig = plugin.HandshakeConfig{
		ProtocolVersion:  ProtocolVersion,
		MagicCookieKey:   MagicCookieKey,
		MagicCookieValue: MagicCookieTask,
	}
)

Functions

func ServeCmd

func ServeCmd(plugins plugin.PluginSet)

ServeCmd serves the given command plugins.

ServeCmd doesn't return until the plugin is done being executed. Any fixable errors will be output to os.Stderr and the process will exit with a status code of 1. Serve will panic for unexpected conditions where a user's fix is unknown.

This is the method that command plugins should call in their main() functions.

func ServeTask

func ServeTask(plugins PluginSet)

ServeTask serves the given task plugins.

ServeTask doesn't return until the plugin is done being executed. Any fixable errors will be output to os.Stderr and the process will exit with a status code of 1. Serve will panic for unexpected conditions where a user's fix is unknown.

This is the method that task plugins should call in their main() functions.

Types

type Plugin

type Plugin = plugin.Plugin

Plugin is an alias for the plugin.Plugin interface used in the implementation of Reginald plugins. It is implemented to serve and consume plugins.

type PluginSet

type PluginSet map[string]Plugin

PluginSet is a set of plugins provided to be registered in the plugin server.

type PluginType

type PluginType byte

PluginType represents the type of the plugin.

const (
	PluginTypeCommand PluginType = 1 << iota
	PluginTypeTask
)

The plugin type to use with plugins. The plugin types can be combined using the OR operator.

const PluginTypeNone PluginType = 0

PluginTypeNone is the base plugin type. If the plugin gives this as its plugin type, it is ignored during the plugin discovery.

func (PluginType) IsCommand

func (t PluginType) IsCommand() bool

IsCommand reports whether the PluginType represents a plugin that offers a command plugin.

func (PluginType) IsTask

func (t PluginType) IsTask() bool

IsTask reports whether the PluginType represents a plugin that offers a task plugin.

type Server

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

Server represents a plugin server. Each plugin should create a new plugin server using NewServer and use that to execute the plugin. Server provides the RPC and gRPC capabilities for executing the plugin as well as the command-line implementation for Reginald's plugin discovery.

The plugins must conform the expectation of Reginald. That is, the plugin discovery should be able to execute the plugin with the `--describe` flag so that the plugin returns the plugin implementations it provides in a predefined format that is handled by Server.

func NewServer

func NewServer() Server

Jump to

Keyboard shortcuts

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