plugin

package
v3.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: LGPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProcessorPluginName = "processor"
	ExecutorPluginName  = "executor"
)

The constants below are the names of the plugins that can be dispensed from the plugin server.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "DKRON_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "b29a76488b6f3ca7955c5f769b50641f0fcd88748d8cedecda313d516320ca19",
}

Handshake is the HandshakeConfig used to configure clients and servers.

View Source
var PluginMap = map[string]plugin.Plugin{
	"processor": &ProcessorPlugin{},
	"executor":  &ExecutorPlugin{},
}

PluginMap should be used by clients for the map of plugins.

Functions

func Serve

func Serve(opts *ServeOpts)

Serve serves a plugin. This function never returns and should be the final function called in the main function of the plugin.

Types

type Broker added in v3.1.9

type Broker interface {
	NextId() uint32
	AcceptAndServe(id uint32, s func([]grpc.ServerOption) *grpc.Server)
}

type Config

type Config map[string]string

Config holds a map of the plugin configuration data structure.

type Executor

type Executor interface {
	Execute(args *types.ExecuteRequest, cb StatusHelper) (*types.ExecuteResponse, error)
}

Executor is the interface that we're exposing as a plugin.

type ExecutorClient

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

Here is the gRPC client that GRPCClient talks to.

func (*ExecutorClient) Execute

type ExecutorPlugin

type ExecutorPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	Executor Executor
}

This is the implementation of plugin.Plugin so we can serve/consume this. We also implement GRPCPlugin so that this plugin can be served over gRPC.

func (*ExecutorPlugin) GRPCClient

func (p *ExecutorPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ExecutorPlugin) GRPCServer

func (p *ExecutorPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type ExecutorPluginConfig

type ExecutorPluginConfig map[string]string

ExecutorPluginConfig is the plugin config

type ExecutorServer

type ExecutorServer struct {
	// This is the real implementation
	types.ExecutorServer
	Impl Executor
	// contains filtered or unexported fields
}

Here is the gRPC server that GRPCClient talks to.

func (ExecutorServer) Execute

Execute is where the magic happens

type GRPCStatusHelperClient

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

GRPCStatusHelperClient is an implementation of status updates over RPC.

func (*GRPCStatusHelperClient) Update

func (m *GRPCStatusHelperClient) Update(b []byte, c bool) (int64, error)

type GRPCStatusHelperServer

type GRPCStatusHelperServer struct {
	// This is the real implementation
	types.StatusHelperServer
	Impl StatusHelper
}

GRPCStatusHelperServer is the gRPC server that GRPCClient talks to.

func (*GRPCStatusHelperServer) Update

type Processor

type Processor interface {
	// Main plugin method, will be called when an execution is done.
	Process(args *ProcessorArgs) types.Execution
}

Processor is an interface that wraps the Process method. Plugins must implement this interface.

type ProcessorArgs

type ProcessorArgs struct {
	// The execution to pass to the processor
	Execution types.Execution
	// The configuration for this plugin call
	Config Config
}

ProcessorArgs holds the Execution and PluginConfig for a Processor.

type ProcessorClient

type ProcessorClient struct {
	Broker *plugin.MuxBroker
	Client *rpc.Client
}

ProcessorClient is an implementation that talks over RPC

func (*ProcessorClient) Process

func (e *ProcessorClient) Process(args *ProcessorArgs) types.Execution

Process method that actually call the plugin Process method.

type ProcessorPlugin

type ProcessorPlugin struct {
	Processor Processor
}

ProcessorPlugin RPC implementation

func (*ProcessorPlugin) Client

func (p *ProcessorPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client implements the RPC client

func (*ProcessorPlugin) Server

func (p *ProcessorPlugin) Server(b *plugin.MuxBroker) (interface{}, error)

Server implements the RPC server

type ProcessorServer

type ProcessorServer struct {
	// This is the real implementation
	Broker    *plugin.MuxBroker
	Processor Processor
}

ProcessorServer is the RPC server that client talks to, conforming to the requirements of net/rpc

func (*ProcessorServer) Process

func (e *ProcessorServer) Process(args *ProcessorArgs, resp *types.Execution) error

Process will call the actual Process method of the plugin

type ServeOpts

type ServeOpts struct {
	Processor Processor
	Executor  Executor
}

ServeOpts are the configurations to serve a plugin.

type StatusHelper

type StatusHelper interface {
	Update([]byte, bool) (int64, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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