plugin

package
v0.0.0-...-089673d Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hclog2ZapLogger

type Hclog2ZapLogger struct {
	Zap *zap.Logger
}

Hclog2ZapLogger implements Hashicorp's hclog.Logger interface using Uber's zap.Logger. It's a workaround for plugin system. go-plugin doesn't support other logger than hclog. This logger implements only methods used by the go-plugin.

func (Hclog2ZapLogger) Debug

func (l Hclog2ZapLogger) Debug(msg string, args ...interface{})

Debug implementation.

func (Hclog2ZapLogger) Error

func (l Hclog2ZapLogger) Error(msg string, args ...interface{})

Error implementation.

func (Hclog2ZapLogger) Info

func (l Hclog2ZapLogger) Info(msg string, args ...interface{})

Info implementation.

func (Hclog2ZapLogger) IsDebug

func (l Hclog2ZapLogger) IsDebug() bool

IsDebug implementation.

func (Hclog2ZapLogger) IsError

func (l Hclog2ZapLogger) IsError() bool

IsError implementation.

func (Hclog2ZapLogger) IsInfo

func (l Hclog2ZapLogger) IsInfo() bool

IsInfo implementation.

func (Hclog2ZapLogger) IsTrace

func (l Hclog2ZapLogger) IsTrace() bool

IsTrace implementation.

func (Hclog2ZapLogger) IsWarn

func (l Hclog2ZapLogger) IsWarn() bool

IsWarn implementation.

func (Hclog2ZapLogger) Named

func (l Hclog2ZapLogger) Named(name string) hclog.Logger

Named implementation.

func (Hclog2ZapLogger) ResetNamed

func (l Hclog2ZapLogger) ResetNamed(name string) hclog.Logger

ResetNamed implementation.

func (Hclog2ZapLogger) SetLevel

func (l Hclog2ZapLogger) SetLevel(level hclog.Level)

SetLevel implementation.

func (Hclog2ZapLogger) StandardLogger

func (l Hclog2ZapLogger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger

StandardLogger implementation.

func (Hclog2ZapLogger) Trace

func (l Hclog2ZapLogger) Trace(msg string, args ...interface{})

Trace implementation.

func (Hclog2ZapLogger) Warn

func (l Hclog2ZapLogger) Warn(msg string, args ...interface{})

Warn implementation.

func (Hclog2ZapLogger) With

func (l Hclog2ZapLogger) With(args ...interface{}) hclog.Logger

With implementation.

type Manager

type Manager struct {
	Reacters []*Plugin
	Log      *zap.Logger
}

Manager handles lifecycle of plugin management.

func NewManager

func NewManager(paths []string, log *zap.Logger) (*Manager, error)

NewManager creates new Manager.

func (*Manager) Kill

func (m *Manager) Kill()

Kill disconnects plugins and kill subprocesses.

func (*Manager) React

func (m *Manager) React(event *event.Event) error

React call all plugins' React method. It returns when the first error is returned by a plugin.

type Plugin

type Plugin struct {
	Path    string
	Reacter Reacter
}

Plugin is a generic struct for storing info about a plugin.

type Reacter

type Reacter interface {
	Subscriptions() []Subscription
	React(event eventpkg.Event) error
}

Reacter allows reacting on subscribed event types.

type ReacterClient

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

ReacterClient is a RPC implementation of Reacter.

func (*ReacterClient) React

func (r *ReacterClient) React(event eventpkg.Event) error

React calls plugin implementation.

func (*ReacterClient) Subscriptions

func (r *ReacterClient) Subscriptions() []Subscription

Subscriptions call plugin implementation.

type ReacterRPCPlugin

type ReacterRPCPlugin struct {
	Reacter Reacter
}

ReacterRPCPlugin is the go-plugin's Plugin implementation.

func (*ReacterRPCPlugin) Client

func (r *ReacterRPCPlugin) Client(b *goplugin.MuxBroker, c *rpc.Client) (interface{}, error)

Client provides ReacterClient client.

func (*ReacterRPCPlugin) Server

func (r *ReacterRPCPlugin) Server(*goplugin.MuxBroker) (interface{}, error)

Server hosts ReacterServer.

type ReacterReactArgs

type ReacterReactArgs struct {
	Event eventpkg.Event
}

ReacterReactArgs RPC args

type ReacterReactResponse

type ReacterReactResponse struct {
	Error *goplugin.BasicError
}

ReacterReactResponse RPC response

type ReacterServer

type ReacterServer struct {
	Reacter Reacter
}

ReacterServer is a net/rpc compatibile structure for serving a Reacter.

func (*ReacterServer) React

React server implementation.

func (*ReacterServer) Subscriptions

func (r *ReacterServer) Subscriptions(_ interface{}, resp *ReacterSubscriptionsResponse) error

Subscriptions server implementation.

type ReacterSubscriptionsResponse

type ReacterSubscriptionsResponse struct {
	Subscriptions []Subscription
}

ReacterSubscriptionsResponse RPC response

type Subscription

type Subscription struct {
	EventType eventpkg.TypeName
	Type
}

Subscription use by plugin to indicate which event it wants to react to.

type Type

type Type int

Type of a subscription.

const (
	// Async subscription type. Plugin host will not block on it.
	Async Type = iota
	// Sync subscription type. Plugin host will use the response from the plugin before proceeding.
	Sync
)

Directories

Path Synopsis
example
Package shared contains shared data between the host and plugins.
Package shared contains shared data between the host and plugins.

Jump to

Keyboard shortcuts

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