plugins

package
v0.0.0-...-8049898 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2017 License: Apache-2.0 Imports: 11 Imported by: 3

README

Plugins Library

Documentation

Index

Constants

View Source
const PluginResponseTimeout time.Duration = 10 * time.Second

PluginResponseTimeout sets the maximum duration allowed to respond to a request for a Plugin Service action (start/stop/status).

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	Service Service
}

Plugin is the main structure for a Plugin hosted in an executable.

func NewPlugin

func NewPlugin(service Service) (*Plugin, error)

NewPlugin returns a new Plugin object.

func (*Plugin) Serve

func (p *Plugin) Serve()

Serve should be called by the Plugin executable and will block allowing the plugin to execute via the Service interface.

func (*Plugin) Start

Start implements the gRPC Start call and proxies it to the Service interface.

func (*Plugin) Status

Status implements the gRCP Status call and proxies it to the Service interface.

func (*Plugin) Stop

Stop implements the gRPC Stop call and proxies it to the Service interface.

type PluginHost

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

PluginHost encapsulates a collection of PluginProcesses and manages their lifecycles.

func NewPluginHost

func NewPluginHost(address string, port int, plugins []string) (*PluginHost, error)

NewPluginHost returns a new PluginHost.

func (*PluginHost) Serve

func (h *PluginHost) Serve()

Serve loads and manages all Plugins.

func (*PluginHost) Start

Start implements the gRPC plugin host API and starts the requested plugin.

func (*PluginHost) Status

func (h *PluginHost) Status(in *host.StatusRequest, stream host.Host_StatusServer) error

Status implements the gRPC plugin host API and gets status on all plugins.

func (*PluginHost) Stop

Stop implements the gRPC plugin host API and stops the requested plugin.

type PluginProcess

type PluginProcess struct {
	Name string
	// contains filtered or unexported fields
}

PluginProcess encapsulates plugin process lifecycle as managed by the Plugin Host.

func NewPluginProcess

func NewPluginProcess(name string) *PluginProcess

NewPluginProcess returns a new PluginProcess.

func (*PluginProcess) Restartable

func (p *PluginProcess) Restartable() bool

Restartable returns a bool indicating whether the PluginProcess should be restarted by the host if the process ends. It's assumed to restart unless an API call was made to the Plugin Host to set the PluginProcess to stop.

func (*PluginProcess) Start

func (p *PluginProcess) Start(notify chan<- *PluginProcess) error

Start brings up the PluginProcess providing a channel for the plugin to notify when the process ends. It redirects stdout/stderr to the host console and also contacts the PluginProcess over gRPC to le it know it can start.

func (*PluginProcess) Status

func (p *PluginProcess) Status() bool

Status returns a bool indicating whether the PluginProcess is running.

func (*PluginProcess) Stop

func (p *PluginProcess) Stop() error

Stop contacts a running PluginProcess over gRPC and asks it to shut down then it kills the PluginProcess if it hasn't shutdown in a suitable amount of time.

type Service

type Service interface {
	Start(context.Context) error
	Stop(context.Context) error
	Status(context.Context) error
}

Service is an interface plugins need to implement in order to interact with the PluginHost.

Directories

Path Synopsis
grpc
host
Package host is a generated protocol buffer package.
Package host is a generated protocol buffer package.
plugin
Package plugin is a generated protocol buffer package.
Package plugin is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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