plugins

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluginHandshake = hcplugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "GOTMPL_PLUGIN",
	MagicCookieValue: "GOTMPL_PLUGIN",
}

PluginHandshake is the handshake config for plugins.

Functions

func InitPlugins

func InitPlugins(ctx context.Context, commands, grpcAddresses []string, options *InitPluginsOptions) (template.FuncMap, error)

InitPlugins initializes both command and grpc plugins and returns a single template.FuncMap that contains functions from all plugins with grpc plugins taking precedence over command plugins with the same name. When multiple plugins have the same name within the same type, the last one will be used. Command plugins will be killed when ctx is canceled.

func NewGrpcServer

func NewGrpcServer(p Plugin) pluginv1.PluginServiceServer

Types

type InitPluginsOptions

type InitPluginsOptions struct {
	// ExecTimeout is the timeout calling ExecuteFunction on a plugin. Defaults to no timeout.
	ExecTimeout time.Duration
	// FunctionsTimeout is the timeout calling ListFunctions on a plugin. Defaults to no timeout.
	FunctionsTimeout time.Duration
}

type Plugin

type Plugin interface {
	ListFunctions(ctx context.Context) ([]string, error)
	ExecuteFunction(ctx context.Context, name string, args []any) (any, error)
}

Plugin is the interface that plugins must implement.

type PluginServer

type PluginServer struct {
	hcplugin.Plugin
	GotmplPlugin Plugin
}

func (*PluginServer) GRPCClient

func (p *PluginServer) GRPCClient(_ context.Context, _ *hcplugin.GRPCBroker, c *grpc.ClientConn) (any, error)

func (*PluginServer) GRPCServer

func (p *PluginServer) GRPCServer(_ *hcplugin.GRPCBroker, s *grpc.Server) error

Jump to

Keyboard shortcuts

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