plugin

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GRPCClient

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

GRPCClient represents gRPC client

func (*GRPCClient) ExecuteJob

func (m *GRPCClient) ExecuteJob(job *proto.Job) (*proto.JobResult, error)

ExecuteJob triggers the execution of the given job in the plugin.

func (*GRPCClient) GetJobs

func (m *GRPCClient) GetJobs() (proto.Plugin_GetJobsClient, error)

GetJobs requests all jobs from the plugin. We get a stream of proto.Job back.

type Plugin

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

Plugin represents a single plugin instance which uses gRPC to connect to exactly one plugin.

func NewPlugin

func NewPlugin(command *exec.Cmd, logPath *string) (p *Plugin, err error)

NewPlugin creates a new instance of Plugin. One Plugin instance represents one connection to a plugin.

It expects the start command to start the plugin and the log path (including file) where the output should be logged to.

func (*Plugin) Close

func (p *Plugin) Close()

Close shutdown the plugin and kills the gRPC connection. Remember to call this when you call plugin.Connect.

func (*Plugin) Connect

func (p *Plugin) Connect() error

Connect starts the plugin, initiates the gRPC connection and looks up the plugin. It's up to the caller to call plugin.Close to shutdown the plugin and close the gRPC connection.

func (*Plugin) Execute

func (p *Plugin) Execute(j *gaia.Job) error

Execute triggers the execution of one single job for the given plugin.

func (*Plugin) GetJobs

func (p *Plugin) GetJobs() ([]gaia.Job, error)

GetJobs receives all implemented jobs from the given plugin.

type PluginGRPC

type PluginGRPC interface {
	GetJobs() (proto.Plugin_GetJobsClient, error)
	ExecuteJob(job *proto.Job) (*proto.JobResult, error)
}

PluginGRPC is the Gaia plugin interface used for communication with the plugin.

type PluginGRPCImpl

type PluginGRPCImpl struct {
	Impl PluginGRPC

	plugin.NetRPCUnsupportedPlugin
}

PluginGRPCImpl represents the plugin implementation on client side.

func (*PluginGRPCImpl) GRPCClient

func (p *PluginGRPCImpl) GRPCClient(context context.Context, b *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient is the passing method for the gRPC client.

func (*PluginGRPCImpl) GRPCServer

func (p *PluginGRPCImpl) GRPCServer(b *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer is needed here to implement hashicorp plugin.Plugin interface. Real implementation is in the plugin(s).

Jump to

Keyboard shortcuts

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