plugins

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2016 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxBytesReader

func MaxBytesReader(r io.ReadCloser, maxBytes int64, err error) io.ReadCloser

MaxBytesReader is similar to net/http.MaxBytesReader, but lets us choose how to handle an overflow by providing an error. net/http.MaxBytesReader uses net/http internals to render a naff error message. There are other discrepancies with how this detects overflows. Not sure if that will cause issues. If you want to use it as part of an HTTP server, it's probably best to change it so you can provide a callback func, which renders your error message, as returning an error into the middle of the net/http server will not be useful.

Types

type Plugin

type Plugin struct {
	xfer.PluginSpec
	// contains filtered or unexported fields
}

Plugin is the implementation of a plugin. It is responsible for doing the plugin handshake, gathering reports, etc.

func NewPlugin

func NewPlugin(ctx context.Context, socket string, client *http.Client, expectedAPIVersion string, handshakeMetadata map[string]string) (*Plugin, error)

NewPlugin loads and initializes a new plugin. If client is nil, http.DefaultClient will be used.

func (*Plugin) Close

func (p *Plugin) Close()

Close closes the client

func (*Plugin) Control added in v1.0.0

func (p *Plugin) Control(request xfer.Request) (res PluginResponse)

Control sends a control message to a plugin

func (*Plugin) Implements added in v1.0.0

func (p *Plugin) Implements(iface string) bool

Implements checks if the plugin implements the given interface

func (*Plugin) Report

func (p *Plugin) Report() (result report.Report, err error)

Report gets the latest report from the plugin

type PluginResponse added in v1.0.0

type PluginResponse struct {
	xfer.Response
	ShortcutReport *report.Report `json:"shortcutReport,omitempty"`
}

PluginResponse is an extension of xfer.Response that allows plugins to send the shortcut reports

type Registry

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

Registry maintains a list of available plugins by name.

func NewRegistry

func NewRegistry(rootPath, apiVersion string, handshakeMetadata map[string]string, handlerRegistry *controls.HandlerRegistry, publisher ReportPublisher) (*Registry, error)

NewRegistry creates a new registry which watches the given dir root for new plugins, and adds them.

func (*Registry) Close

func (r *Registry) Close()

Close shuts down the registry. It can still be used after this, but will be out of date.

func (*Registry) ForEach

func (r *Registry) ForEach(f func(p *Plugin))

ForEach walks through all the plugins running f for each one.

func (*Registry) Implementers

func (r *Registry) Implementers(iface string, f func(p *Plugin))

Implementers walks the available plugins fulfilling the given interface

func (*Registry) Name

func (r *Registry) Name() string

Name implements the Reporter interface

func (*Registry) Report

func (r *Registry) Report() (report.Report, error)

Report implements the Reporter interface

type ReportPublisher added in v1.0.0

type ReportPublisher interface {
	Publish(rpt report.Report)
}

ReportPublisher is an interface for publishing reports immediately

Jump to

Keyboard shortcuts

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