plugin

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GaiaLogWriter added in v0.2.4

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

GaiaLogWriter represents a concurrent safe log writer which can be shared with go-plugin.

func (*GaiaLogWriter) Flush added in v0.2.4

func (g *GaiaLogWriter) Flush() error

Flush locks and flushes the underlying writer.

func (*GaiaLogWriter) Write added in v0.2.4

func (g *GaiaLogWriter) Write(p []byte) (n int, err error)

Write locks and writes to the underlying writer.

func (*GaiaLogWriter) WriteString added in v0.2.4

func (g *GaiaLogWriter) WriteString(s string) (int, error)

WriteString locks and passes on the string to write to the underlying writer.

type GaiaPlugin added in v0.2.4

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

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

type GaiaPluginClient added in v0.2.4

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

GaiaPluginClient represents gRPC client

func (*GaiaPluginClient) ExecuteJob added in v0.2.4

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

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

func (*GaiaPluginClient) GetJobs added in v0.2.4

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

type GaiaPluginImpl added in v0.2.4

type GaiaPluginImpl struct {
	Impl GaiaPlugin

	plugin.NetRPCUnsupportedPlugin
}

GaiaPluginImpl represents the plugin implementation on client side.

func (*GaiaPluginImpl) GRPCClient added in v0.2.4

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

GRPCClient is the passing method for the gRPC client.

func (*GaiaPluginImpl) GRPCServer added in v0.2.4

func (p *GaiaPluginImpl) 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).

type GoPlugin added in v0.2.4

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

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

func (*GoPlugin) Close added in v0.2.4

func (p *GoPlugin) Close()

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

func (*GoPlugin) Execute added in v0.2.4

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

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

func (*GoPlugin) FlushLogs added in v0.2.4

func (p *GoPlugin) FlushLogs() error

FlushLogs flushes the logs.

func (*GoPlugin) GetJobs added in v0.2.4

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

GetJobs receives all implemented jobs from the given plugin.

func (*GoPlugin) Init added in v0.2.4

func (p *GoPlugin) Init(command *exec.Cmd, logPath *string) error

Init prepares the log path, set's up new certificates for both gaia and plugin, and prepares the go-plugin client.

It expects the start command for the plugin and the path where the log file should be stored.

It's up to the caller to call plugin.Close to shutdown the plugin and close the gRPC connection.

func (*GoPlugin) NewPlugin added in v0.2.4

func (p *GoPlugin) NewPlugin(ca security.CAAPI) Plugin

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

func (*GoPlugin) Validate added in v0.2.4

func (p *GoPlugin) Validate() error

Validate validates the interface of the plugin.

type Plugin

type Plugin interface {
	// NewPlugin creates a new instance of plugin
	NewPlugin(ca security.CAAPI) Plugin

	// Init initializes the go-plugin client and generates a
	// new certificate pair for gaia and the plugin/pipeline.
	Init(command *exec.Cmd, logPath *string) error

	// Validate validates the plugin interface.
	Validate() error

	// Execute executes one job of a pipeline.
	Execute(j *gaia.Job) error

	// GetJobs returns all real jobs from the pipeline.
	GetJobs() ([]*gaia.Job, error)

	// FlushLogs flushes the logs.
	FlushLogs() error

	// Close closes the connection and cleans open file writes.
	Close()
}

Plugin represents the plugin implementation.

Jump to

Keyboard shortcuts

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