plugin

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// ServicePackPluginName ...
	ServicePackPluginName = "servicepack"
)

Variables

This section is empty.

Functions

func GetHandshakeConfig

func GetHandshakeConfig() hcplugin.HandshakeConfig

GetHandshakeConfig provides handshake config details. It is used by core and service packs.

func Serve

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.

Types

type ServeOpts

type ServeOpts struct {
	//Interface implementation
	Pack ServicePack

	// Logger is the logger that go-plugin will use.
	Logger hclog.Logger

	// Set NoLogOutputOverride to not override the log output with an hclog
	// adapter. This should only be used when running the plugin in
	// acceptance tests.
	NoLogOutputOverride bool
}

ServeOpts are the configurations to serve a plugin.

type ServicePack

type ServicePack interface {
	RunProbes() error
}

ServicePack is the interface that we're exposing as a plugin.

type ServicePackPlugin

type ServicePackPlugin struct {
	// Impl Injection
	Impl ServicePack
}

ServicePackPlugin is the implementation of plugin.Plugin so we can serve/consume this

This has two methods: Server must return an RPC server for this plugin type. We construct a GreeterRPCServer for this.

Client must return an implementation of our interface that communicates over an RPC client. We return GreeterRPC for this.

Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.

func (ServicePackPlugin) Client

func (ServicePackPlugin) Client(b *hcplugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client implements RPC client

func (*ServicePackPlugin) Server

func (p *ServicePackPlugin) Server(*hcplugin.MuxBroker) (interface{}, error)

Server implements RPC server

type ServicePackRPC

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

ServicePackRPC is an implementation that talks over RPC

func (*ServicePackRPC) RunProbes

func (g *ServicePackRPC) RunProbes() error

RunProbes returns a message

type ServicePackRPCServer

type ServicePackRPCServer struct {
	// This is the real implementation
	Impl ServicePack
}

ServicePackRPCServer is the RPC server that ServicePackRPC talks to, conforming to the requirements of net/rpc

func (*ServicePackRPCServer) RunProbes

func (s *ServicePackRPCServer) RunProbes(args interface{}, resp *error) error

RunProbes is a wrapper for interface implementation

Jump to

Keyboard shortcuts

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