dkron: Index | Files | Directories

package plugin

import ""


Package Files

execution_processor.go executor.go plugin.go serve.go


const (
    ProcessorPluginName = "processor"
    ExecutorPluginName  = "executor"

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


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.

func Serve Uses

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.

type Config Uses

type Config map[string]string

Config holds a map of the plugin configuration data structure.

type Executor Uses

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 Uses

type ExecutorClient struct {
    // contains filtered or unexported fields

Here is the gRPC client that GRPCClient talks to.

func (*ExecutorClient) Execute Uses

func (m *ExecutorClient) Execute(args *types.ExecuteRequest, cb StatusHelper) (*types.ExecuteResponse, error)

type ExecutorPlugin Uses

type ExecutorPlugin struct {
    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 Uses

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

func (*ExecutorPlugin) GRPCServer Uses

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

type ExecutorPluginConfig Uses

type ExecutorPluginConfig map[string]string

ExecutorPluginConfig is the plugin config

type ExecutorServer Uses

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

Here is the gRPC server that GRPCClient talks to.

func (ExecutorServer) Execute Uses

func (m ExecutorServer) Execute(ctx context.Context, req *types.ExecuteRequest) (*types.ExecuteResponse, error)

Execute is where the magic happens

type GRPCStatusHelperClient Uses

type GRPCStatusHelperClient struct {
    // contains filtered or unexported fields

GRPCStatusHelperClient is an implementation of status updates over RPC.

func (*GRPCStatusHelperClient) Update Uses

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

type GRPCStatusHelperServer Uses

type GRPCStatusHelperServer struct {
    // This is the real implementation
    Impl StatusHelper

GRPCStatusHelperServer is the gRPC server that GRPCClient talks to.

func (*GRPCStatusHelperServer) Update Uses

func (m *GRPCStatusHelperServer) Update(ctx context.Context, req *types.StatusUpdateRequest) (resp *types.StatusUpdateResponse, err error)

type Processor Uses

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 Uses

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 Uses

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

ProcessorClient is an implementation that talks over RPC

func (*ProcessorClient) Process Uses

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

Process method that actually call the plugin Process method.

type ProcessorPlugin Uses

type ProcessorPlugin struct {
    Processor Processor

ProcessorPlugin RPC implementation

func (*ProcessorPlugin) Client Uses

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

Client implements the RPC client

func (*ProcessorPlugin) Server Uses

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

Server implements the RPC server

type ProcessorServer Uses

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 Uses

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

Process will call the actuall Process method of the plugin

type ServeOpts Uses

type ServeOpts struct {
    Processor Processor
    Executor  Executor

ServeOpts are the configurations to serve a plugin.

type StatusHelper Uses

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



Package plugin imports 5 packages (graph). Updated 2020-05-29. Refresh now. Tools for package owners.