shared

package
v3.0.0-...-e9d5d1c Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package shared contains shared data between the host and plugins.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{

	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Handshake is 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.

View Source
var PluginMap = map[string]plugin.Plugin{
	"customPlugin": &CustomPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

func SetupDefaults

func SetupDefaults() map[string]interface{}

func SetupLogrus

func SetupLogrus(info LogrusInfo) error

Types

type CustomPlugin

type CustomPlugin struct {
	// CustomPlugin must still implement the Plugin interface
	plugin.Plugin
	// Concrete implementation, written in Go. This is only used for plugins
	// that are written in Go.
	Impl Service
}

CustomPlugin This 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 (CustomPlugin) Client

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

func (*CustomPlugin) Server

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

type LogrusInfo

type LogrusInfo struct {
	// Version is injected by go (should be a tag name)
	Version string
	// Buildstamp is a timestamp (injected by go) of the build time
	Buildstamp string
	// Githash is the tag for current hash the build represents
	Githash string
}

type PluginRPC

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

PluginRPC is an implementation that talks over RPC

type PluginRPCServer

type PluginRPCServer struct {
	// This is the real implementation
	Impl Service
}

PluginRPCServer is the RPC server that GreeterRPC talks to, conforming to the requirements of net/rpc

func (*PluginRPCServer) Start

func (s *PluginRPCServer) Start(args interface{}, resp *string) error

type Service

type Service interface {
	Start()
	Stop()
}

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

Jump to

Keyboard shortcuts

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