pluginInternal

package
v0.0.0-...-4e72bd7 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const GRPCPluginName = PluginName + "_grpc"
View Source
const PluginName = "debugtalk"
View Source
const RPCPluginName = PluginName + "_rpc"

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "HttpRunnerPlus",
	MagicCookieValue: PluginName,
}

handshakeConfigs are used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.

Functions

func IsRPCPluginType

func IsRPCPluginType() bool

Types

type FuncCaller

type FuncCaller interface {
	GetNames() ([]string, error)                                    // get all plugin function names list
	Call(funcName string, args ...interface{}) (interface{}, error) // call plugin function
}

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

type GRPCPlugin

type GRPCPlugin struct {
	plugin.Plugin
	Impl FuncCaller
}

HRPPlugin implements hashicorp's plugin.GRPCPlugin.

func (*GRPCPlugin) GRPCClient

func (p *GRPCPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*GRPCPlugin) GRPCServer

func (p *GRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

type GoPlugin

type GoPlugin struct {
	*plugin.Plugin
	// contains filtered or unexported fields
}

GoPlugin implements golang official plugin

func (*GoPlugin) Call

func (p *GoPlugin) Call(funcName string, args ...interface{}) (interface{}, error)

func (*GoPlugin) Has

func (p *GoPlugin) Has(funcName string) bool

func (*GoPlugin) Init

func (p *GoPlugin) Init(path string) error

func (*GoPlugin) Quit

func (p *GoPlugin) Quit() error

type HashicorpPlugin

type HashicorpPlugin struct {
	FuncCaller
	// contains filtered or unexported fields
}

HashicorpPlugin implements hashicorp/go-plugin

func (*HashicorpPlugin) Call

func (p *HashicorpPlugin) Call(funcName string, args ...interface{}) (interface{}, error)

func (*HashicorpPlugin) Has

func (p *HashicorpPlugin) Has(funcName string) bool

func (*HashicorpPlugin) Init

func (p *HashicorpPlugin) Init(path string) error

func (*HashicorpPlugin) Quit

func (p *HashicorpPlugin) Quit() error

type IPlugin

type IPlugin interface {
	Init(path string) error                                         // init plugin
	Has(funcName string) bool                                       // check if plugin has function
	Call(funcName string, args ...interface{}) (interface{}, error) // call function
	Quit() error                                                    // quit plugin
}

func Init

func Init(path string, logOn bool) (IPlugin, error)

type RPCPlugin

type RPCPlugin struct {
	Impl FuncCaller
}

RPCPlugin implements hashicorp's plugin.Plugin.

func (RPCPlugin) Client

func (RPCPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)

func (*RPCPlugin) Server

func (p *RPCPlugin) Server(*plugin.MuxBroker) (interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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