Documentation ¶
Index ¶
Constants ¶
const ( ProtocolVersion uint = 1 MagicCookieKey = "REGINALD_PLUGIN" MagicCookie = "plugin" )
Helper values for creating the handshake configuration for the plugin server.
const ( ExitSuccess = 0 ExitMarshalError = 2 // marshaling the descriptor failed )
Exit codes for the `--describe` functionality of the plugin server executable.
Variables ¶
var ErrEmptyPlugin = errors.New("plugin specified no commands or tasks")
var HandshakeConfig = plugin.HandshakeConfig{ ProtocolVersion: ProtocolVersion, MagicCookieKey: MagicCookieKey, MagicCookieValue: MagicCookie, }
Set handshake configs for the plugin servers and clients.
Functions ¶
This section is empty.
Types ¶
type CmdPlugin ¶
CmdPlugin is the implementation of Plugin for commands. It is used for serving and consuming a command plugin.
To serve a command given as Impl from a plugin, use the CmdPlugin.Server function to get the RPC server. It contructs and serves a CmdRPCServer.
To consume a command as a client from a plugin, use the CmdPlugin.Client function to get the RPC client. It contructs and serves a CmdRPC.
func (*CmdPlugin) Client ¶
Client returns the client implementation of command.Command for the CmdPlugin.
type CmdRPC ¶
type CmdRPC struct {
// contains filtered or unexported fields
}
CmdRPC is a command.Command implementation that talks over RPC. It is the client that consumes a plugin. The RPC client can be obtained with CmdPlugin.Client.
type CmdRPCServer ¶
CmdRPCServer is a command.Command implementation used on the RPC server (the plugin) that the client-side CmdRPC talks to over RPC. The RPC server can be obtained with CmdPlugin.Server.
type Descriptor ¶
type Descriptor struct { Name string `json:"name"` // name of the plugin ProtocolVersion uint `json:"protocolVersion"` // protocol version used by plugin Commands []string `json:"commands"` // commands the plugin provided, can be empty or nil Tasks []string `json:"tasks"` // tasks the plugin provided, can be empty or nil }
Descriptor describes the plugin when Reginald request for information on the plugins during discovery.
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 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.
type TaskPlugin ¶
TaskPlugin is the implementation of Plugin for tasks. It is used for serving and consuming a task plugin.
To serve a task given as Impl from a plugin, use the TaskPlugin.Server function to get the RPC server. It contructs and serves a TaskRPCServer.
To consume a task as a client from a plugin, use the TaskPlugin.Client function to get the RPC client. It contructs and serves a TaskRPC.
func (*TaskPlugin) Client ¶
func (p *TaskPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (any, error)
Client returns the client implementation of task.Task for the TaskPlugin.
func (*TaskPlugin) Server ¶
func (p *TaskPlugin) Server(_ *plugin.MuxBroker) (any, error)
Server returns the server implementation of task.Task for the TaskPlugin.
type TaskRPC ¶
type TaskRPC struct {
// contains filtered or unexported fields
}
TaskRPC is a task.Task implementation that talks over RPC. It is the client that consumes a plugin. The RPC client can be obtained with TaskPlugin.Client.
type TaskRPCServer ¶
TaskRPCServer is a task.Task implementation used on the RPC server (the plugin) that the client-side TaskRPC talks to over RPC. The RPC server can be obtained with TaskPlugin.Server.
func (*TaskRPCServer) Check ¶
func (s *TaskRPCServer) Check(settings task.Settings, resp *error) error
func (*TaskRPCServer) CheckDefaults ¶
func (s *TaskRPCServer) CheckDefaults(settings task.Settings, resp *error) error