plugin

package
v0.0.0-...-a355528 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {

	// Name is the key used to refer to this plugin in all JSON configs
	Name string

	// Protocol is the transport protocol -- unix, tcp, etc.
	Protocol string

	// Address is the how to connect - socket file, host:port, etc.
	Address string
}

Endpoint is the address of the plugin service

type Info

type Info struct {

	// Vendor captures vendor-specific information about this plugin
	Vendor *spi.VendorInfo

	// Implements is a list of plugin interface and versions this plugin supports
	Implements []spi.InterfaceSpec

	// Interfaces (optional) is a slice of interface descriptions by the type and version
	Interfaces []InterfaceDescription `json:",omitempty"`
}

Info is metadata for the plugin

type Informer

type Informer interface {

	// GetInfo returns metadata about the plugin
	GetInfo() (Info, error)

	// GetFunctions returns metadata about the plugin's template functions, if the plugin supports templating.
	GetFunctions() (map[string][]template.Function, error)
}

Informer is the interface that gives information about the plugin such as version and interface methods

type InterfaceDescription

type InterfaceDescription struct {
	spi.InterfaceSpec
	Methods []MethodDescription
}

InterfaceDescription is a holder for RPC interface version and method descriptions

type Metadata

type Metadata struct {
	// Kind is the kind of the plugin (e.g. group, ingress, aws)
	Kind string
	// Name is the endpoint of the object
	Name Name
	// Instance is optionally a key for an object indexable within the remote plugin
	Instance string
	// InterfaceSpec is the interface definition of the remote object
	InterfaceSpec spi.InterfaceSpec
}

Metadata describes the plugin

type MethodDescription

type MethodDescription struct {
	// Request is the RPC request example
	Request Request

	// Response is the RPC response example
	Response Response
}

MethodDescription contains information about the RPC method such as the request and response example structs. The request value can be used as an example input, possibly with example plugin-custom properties if the underlying plugin implements the InputExample interface. The response value gives an example of the example response.

type Name

type Name string

Name is a reference to the plugin. Places where it appears include JSON files as type of field `Plugin`.

func NameFrom

func NameFrom(lookup, sub string) Name

NameFrom creates a name from the parts

func (Name) Equal

func (n Name) Equal(other Name) bool

Equal returns true if the other name is the same

func (Name) GetLookupAndType

func (n Name) GetLookupAndType() (string, string)

GetLookupAndType returns the plugin name for lookup and sub-type supported by the plugin. The name follows a microformat of $plugin[/$subtype] where $plugin is used for the discovery / lookup by name. The $subtype is used for the Type parameter in the RPC requests. Example: instance-file/json means lookup socket file 'instance-file' and the type is 'json'.

func (Name) HasType

func (n Name) HasType() bool

HasType returns true if the name is of the form lookup/type

func (Name) IsEmpty

func (n Name) IsEmpty() bool

IsEmpty returns true if the name is an empty string

func (Name) Lookup

func (n Name) Lookup() string

Lookup returns the lookup portion of the name

func (Name) LookupOnly

func (n Name) LookupOnly() Name

LookupOnly returns the trailing slash form e.g. us-east/

func (Name) MarshalJSON

func (n Name) MarshalJSON() ([]byte, error)

MarshalJSON implements the JSON marshaler interface

func (Name) Rel

func (n Name) Rel(other Name) Name

Rel computes the relative form, assuming the receiver is the base path so that Join(other, n.Rel(other)) == other. If it's not relative at all, then the receiver is returned

func (Name) String

func (n Name) String() string

String returns the string form

func (*Name) UnmarshalJSON

func (n *Name) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the JSON unmarshaler interface

func (Name) WithType

func (n Name) WithType(t interface{}) Name

WithType returns a new name with the same lookup but a different type

type Request

type Request struct {

	// Version is the version of the JSON RPC protocol
	Version string `json:"jsonrpc"`

	// Method is the rpc method to use in the payload field 'method'
	Method string `json:"method"`

	// Params contains example inputs.  This can be a zero value struct or one with defaults
	Params interface{} `json:"params"`

	// ID is the request is
	ID string `json:"id"`
}

Request models the RPC request payload

type Response

type Response struct {

	// Result is the result of the call
	Result interface{} `json:"result"`

	// ID is id matching the request ID
	ID string `json:"id"`
}

Response is the RPC response struct

type Spec

type Spec struct {

	// Plugin is the name of the plugin
	Plugin Name

	// Properties is the configuration of the plugin
	Properties *types.Any
}

Spec models a canonical pattern of fields that exist in a struct/ map / union that indicates the block is a plugin.

type Transport

type Transport struct {
	// Name is the name of the plugin
	Name Name

	// Listen host:port. If not specified, the default behavior is to use unix socket locally
	Listen string

	// Advertise is the host:port used for others to discover this endpoint
	Advertise string

	// Dir is the directory for discovery (ie location of the socket files, etc.)
	// If not specified, it will default to system settings (via environment variable -- see pkg/discovery/local
	Dir string
}

Transport describes how the plugin communicates

func DefaultTransport

func DefaultTransport(name string) Transport

DefaultTransport returns the default transport based on a simple name. The default is to use unix socket, at directory specified by the pkg/discovery/local discovery mechanism.

Jump to

Keyboard shortcuts

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