Documentation ¶
Index ¶
- Constants
- type Plugin
- func (p *Plugin) Serve()
- func (p *Plugin) Start(ctx context.Context, in *plugin.StartRequest) (*plugin.StartResponse, error)
- func (p *Plugin) Status(ctx context.Context, in *plugin.StatusRequest) (*plugin.StatusResponse, error)
- func (p *Plugin) Stop(ctx context.Context, in *plugin.StopRequest) (*plugin.StopResponse, error)
- type PluginHost
- func (h *PluginHost) Serve()
- func (h *PluginHost) Start(ctx context.Context, in *host.StartRequest) (*host.StartResponse, error)
- func (h *PluginHost) Status(in *host.StatusRequest, stream host.Host_StatusServer) error
- func (h *PluginHost) Stop(ctx context.Context, in *host.StopRequest) (*host.StopResponse, error)
- type PluginProcess
- type Service
Constants ¶
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 (*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 ¶
func (p *Plugin) Start(ctx context.Context, in *plugin.StartRequest) (*plugin.StartResponse, error)
Start implements the gRPC Start call and proxies it to the Service interface.
func (*Plugin) Status ¶
func (p *Plugin) Status(ctx context.Context, in *plugin.StatusRequest) (*plugin.StatusResponse, error)
Status implements the gRCP Status call and proxies it to the Service interface.
func (*Plugin) Stop ¶
func (p *Plugin) Stop(ctx context.Context, in *plugin.StopRequest) (*plugin.StopResponse, error)
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) Start ¶
func (h *PluginHost) Start(ctx context.Context, in *host.StartRequest) (*host.StartResponse, error)
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 ¶
func (h *PluginHost) Stop(ctx context.Context, in *host.StopRequest) (*host.StopResponse, error)
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.