metal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package metal provides the entry point for implementing the plugin system in a process.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = goPlugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "ZEDPM_PLUGIN_MAGIC_COOKIE",
	MagicCookieValue: "Q0aHomIRxbv3sa9jlP28A3juUduYTyUnAh4MQnr3",
}

Handshake is the shared Hashicorp plugin handshake object.

Functions

func Dispense

func Dispense(clients Clients, name string) (plugin.Interface, error)

Dispense returns a plugin.Interface for executing parts of a single plugin interface.

func DispenseAll

func DispenseAll(clients Clients) (map[string]plugin.Interface, error)

DispenseAll returns a mapping from plugin name (found in the configuration) to the matching plugin.Interface which is able to execute tasks and operations and so on.

func KillPlugins

func KillPlugins(clients Clients)

KillPlugins will kill all plugins that have been started by LoadPlugins.

func LoadDevModePlugin

func LoadDevModePlugin(
	cfg *config.Config,
	pcfg *config.PluginConfig,
	logger hclog.Logger,
	stdOut io.Writer,
	stdErr io.Writer,
) (*goPlugin.Client, error)

LoadDevModePlugin initializes a plugin that is compiled and run in a single step via the "go run" command.

func LoadLocalPlugin

func LoadLocalPlugin(
	iface plugin.Interface,
	logger hclog.Logger,
	stdOut io.Writer,
	stdErr io.Writer,
) (*goPlugin.Client, error)

LoadLocalPlugin will run the plugin server as a goroutine on the local process and connect the master process to it, essentially talking to itself.

func NewGoPluginClient

func NewGoPluginClient(
	cmd []string,
	logger hclog.Logger,
	stdOut io.Writer,
	stdErr io.Writer,
) *goPlugin.Client

NewGoPluginClient creates a new Hashicorp plugin client to connect to a single configured plugin.

func RunPlugin

func RunPlugin(impl plugin.Interface)

RunPlugin is the function called by a plugin's main function to handle making the plugin.Interface it defines available for execution by the zedpm master process.

Types

type Clients

type Clients map[string]*goPlugin.Client

Clients represents a list of Hashicorp plugins we are running to implement the plugin interface of zedpm.

func LoadPlugins

func LoadPlugins(
	logger hclog.Logger,
	cfg *config.Config,
	stdOut io.Writer,
	stdErr io.Writer,
) (Clients, error)

LoadPlugins will load all the configured plugins by executing their plugin program via the Hashicorp plugin interface for each.

type InterfaceGRPCPlugin

type InterfaceGRPCPlugin struct {
	goPlugin.Plugin
	Impl plugin.Interface
	// contains filtered or unexported fields
}

InterfaceGRPCPlugin defines the plugin interface that zedpm uses to fill in the Hashicorp plugin interface.

func NewPlugin

func NewPlugin(logger hclog.Logger, impl plugin.Interface) *InterfaceGRPCPlugin

NewPlugin creates a new plugin object for the given plugin interface.

func (*InterfaceGRPCPlugin) GRPCClient

GRPCClient returns a new GRPC plugin client for executing a plugin.

func (*InterfaceGRPCPlugin) GRPCServer

func (p *InterfaceGRPCPlugin) GRPCServer(
	_ *goPlugin.GRPCBroker,
	s *grpc.Server,
) error

GRPCServer returns a new GRPC plugin server for implementing a plugin.

type SyncBuffer

type SyncBuffer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SyncBuffer is a simple synchronized buffer.

func NewSyncBuffer

func NewSyncBuffer(w io.Writer) *SyncBuffer

NewSyncBuffer creates a new syncrhonized buffer wrapping the given io.Writer.

func (*SyncBuffer) Write

func (b *SyncBuffer) Write(p []byte) (int, error)

Write calls the Write method of the wrapped io.Writer, but acuires a write lock before performing the operation, ensuring that only a single write is occurring at a given time.

Jump to

Keyboard shortcuts

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