plugin

package
v0.10.25 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecCommand = exec.Command

ExecCommand creates new plugin command

View Source
var ExecCommandContext = exec.CommandContext

ExecCommandContext used to check to create command for checking plugin config

NewDriverClient creates a grpc client for protocol using connection

View Source
var NewPluginClient = DefaultPluginClient

NewPluginClient creates new client for plugin

RegisterDriverServer registers an concrete implementation of a grpc server for a protocol.

Functions

func LoadDriverPlugins

func LoadDriverPlugins(cfg Config) func()

LoadDriverPlugins searches environment PATH for files matching stucco-<plugin-name> executables and adds them as handlers for specific runtimes. Plugin must atleast be runnable with only binary name and if argument config is provided, plugin is expected to list supported runtimes in JSON and exit.

func NewLogger

func NewLogger(name string) hclog.Logger

NewLogger replaces hclog used by go-plugin with klog for consistency

Types

type Client

type Client interface {
	Client() (plugin.ClientProtocol, error)
	Kill()
}

Client interface used to establish connection with plugin

func DefaultPluginClient

func DefaultPluginClient(cfg *plugin.ClientConfig) Client

DefaultPluginClient creates a default plugin client

type Config

type Config struct {
	// defines how many concurrent clients for request can be open at once
	Runners uint8
	// Cmd is an executable path to plugin
	Cmd string
}

Config is a plugin configuration

type GRPC

type GRPC struct {
	plugin.Plugin
	Authorize                     grpc.AuthorizeHandler
	FieldResolveHandler           grpc.FieldResolveHandler
	InterfaceResolveTypeHandler   grpc.InterfaceResolveTypeHandler
	ScalarParseHandler            grpc.ScalarParseHandler
	ScalarSerializeHandler        grpc.ScalarSerializeHandler
	UnionResolveTypeHandler       grpc.UnionResolveTypeHandler
	SetSecretsHandler             grpc.SetSecretsHandler
	StreamHandler                 grpc.StreamHandler
	StdoutHandler                 grpc.StdoutHandler
	StderrHandler                 grpc.StderrHandler
	SubscriptionConnectionHandler grpc.SubscriptionConnectionHandler
	SubscriptionListenHandler     grpc.SubscriptionListenHandler
}

GRPC implement GRPCPlugin interface fro go-plugin

func (*GRPC) GRPCClient

func (g *GRPC) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *googlegrpc.ClientConn) (interface{}, error)

GRPCClient returns a client implementation for go-plugin

func (*GRPC) GRPCServer

func (g *GRPC) GRPCServer(broker *plugin.GRPCBroker, s *googlegrpc.Server) error

GRPCServer returns a server implementation for go-plugin

type Plugin

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

Plugin implements Driver interface by running an executable available on local fs. All user defined operations will be forwarded to plugin through GRPC protocol.

func NewPlugin

func NewPlugin(cfg Config) *Plugin

NewPlugin creates new plugin ready to be used. Plugin must be closed after usage

func (*Plugin) Authorize

Authorize uses plugin to authorize request

func (*Plugin) Close

func (p *Plugin) Close() (err error)

Close plugin and stop all runners

func (*Plugin) FieldResolve

FieldResolve uses plugin to resolve a field on type

func (*Plugin) InterfaceResolveType

InterfaceResolveType uses plugin to find interface type for user input

func (*Plugin) ScalarParse

ScalarParse uses plugin to parse scalar

func (*Plugin) ScalarSerialize

ScalarSerialize uses plugin to serialize scalar

func (*Plugin) SetSecrets

SetSecrets sets user provided secrets for plugin using environment variables

func (*Plugin) Stream

Stream data through grpc plugin

func (*Plugin) SubscriptionConnection

SubscriptionConnection creates connection with plugin

func (*Plugin) SubscriptionListen

SubscriptionListen creates listen stream with plugin

func (*Plugin) UnionResolveType

UnionResolveType uses plugin to find union type for user input

Jump to

Keyboard shortcuts

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