Documentation ¶
Index ¶
- Constants
- Variables
- func Serve(opts *ServeOpts)
- type Broker
- type Config
- type Executor
- type ExecutorClient
- type ExecutorPlugin
- type ExecutorPluginConfig
- type ExecutorServer
- type GRPCStatusHelperClient
- type GRPCStatusHelperServer
- type Processor
- type ProcessorArgs
- type ProcessorClient
- type ProcessorPlugin
- type ProcessorServer
- type ServeOpts
- type StatusHelper
Constants ¶
const ( ProcessorPluginName = "processor" ExecutorPluginName = "executor" )
The constants below are the names of the plugins that can be dispensed from the plugin server.
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "DKRON_PLUGIN_MAGIC_COOKIE",
MagicCookieValue: "b29a76488b6f3ca7955c5f769b50641f0fcd88748d8cedecda313d516320ca19",
}
Handshake is the HandshakeConfig used to configure clients and servers.
var PluginMap = map[string]plugin.Plugin{ "processor": &ProcessorPlugin{}, "executor": &ExecutorPlugin{}, }
PluginMap should be used by clients for the map of plugins.
Functions ¶
Types ¶
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 ¶
func (m *ExecutorClient) Execute(args *types.ExecuteRequest, cb StatusHelper) (*types.ExecuteResponse, error)
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 ¶
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 ¶
func (m ExecutorServer) Execute(ctx context.Context, req *types.ExecuteRequest) (*types.ExecuteResponse, error)
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.
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 ¶
func (m *GRPCStatusHelperServer) Update(ctx context.Context, req *types.StatusUpdateRequest) (resp *types.StatusUpdateResponse, err error)
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 ¶
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