rpc

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: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// URLAPI is the well-known HTTP GET endpoint that retrieves description of the plugin's interfaces.
	URLAPI = "/info/api.json"

	// URLFunctions exposes the templates functions that are available via this plugin
	URLFunctions = "/info/functions.json"

	// URLEventsPrefix is the prefix of the events endpoint
	URLEventsPrefix = "/events"
)
View Source
const DefaultRemoteAddr = "1.2.3.4"

DefaultRemoteAddr is the default remote address to return in RemoteAddr if an explicit DefaultRemoteAddr isn't set on ResponseRecorder.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handshake

type Handshake map[spi.InterfaceSpec]func() []string

Handshake is a simple RPC object for doing handshake

func (Handshake) Implements

func (h Handshake) Implements(_ *http.Request, req *ImplementsRequest, resp *ImplementsResponse) error

Implements responds to a request for the supported plugin interfaces.

func (Handshake) Types

func (h Handshake) Types(_ *http.Request, req *TypesRequest, resp *TypesResponse) error

Types returns a list of types exposed by this object

type Handshaker

type Handshaker interface {
	// Implementes returns a list of interface specs implemented by this object
	Implements() ([]spi.InterfaceSpec, error)

	// Types returns a list of types exposed by this object
	Types() (map[InterfaceSpec][]string, error)
}

Handshaker is the interface implemented by all rpc objects that can give information about the interfaces it implements

type ImplementsRequest

type ImplementsRequest struct {
}

ImplementsRequest is the rpc wrapper for the Implements method args.

type ImplementsResponse

type ImplementsResponse struct {
	APIs []spi.InterfaceSpec
}

ImplementsResponse is the rpc wrapper for the Implements return value.

type InputExample

type InputExample interface {

	// SetExampleProperties updates the parameter with example properties.
	// The request param must be a pointer
	SetExampleProperties(request interface{})
}

InputExample is the interface implemented by the rpc implementations for group, instance, and flavor to set example input using custom/ vendored data types.

type InterfaceSpec

type InterfaceSpec string

InterfaceSpec is the string version of the InterfaceSpec

type ResponseRecorder

type ResponseRecorder struct {
	Code      int           // the HTTP response code from WriteHeader
	HeaderMap http.Header   // the HTTP response headers
	Body      *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to
	Flushed   bool
	// contains filtered or unexported fields
}

ResponseRecorder is an implementation of http.ResponseWriter that records its mutations for later inspection in tests.

func NewRecorder

func NewRecorder() *ResponseRecorder

NewRecorder returns an initialized ResponseRecorder.

func (*ResponseRecorder) Flush

func (rw *ResponseRecorder) Flush()

Flush sets rw.Flushed to true.

func (*ResponseRecorder) Header

func (rw *ResponseRecorder) Header() http.Header

Header returns the response headers.

func (*ResponseRecorder) Result

func (rw *ResponseRecorder) Result() *http.Response

Result returns the response generated by the handler.

The returned Response will have at least its StatusCode, Header, Body, and optionally Trailer populated. More fields may be populated in the future, so callers should not DeepEqual the result in tests.

The Response.Header is a snapshot of the headers at the time of the first write call, or at the time of this call, if the handler never did a write.

Result must only be called after the handler has finished running.

func (*ResponseRecorder) Write

func (rw *ResponseRecorder) Write(buf []byte) (int, error)

Write always succeeds and writes to rw.Body, if not nil.

func (*ResponseRecorder) WriteHeader

func (rw *ResponseRecorder) WriteHeader(code int)

WriteHeader sets rw.Code. After it is called, changing rw.Header will not affect rw.HeaderMap.

func (*ResponseRecorder) WriteString

func (rw *ResponseRecorder) WriteString(str string) (int, error)

WriteString always succeeds and writes to rw.Body, if not nil.

type TypesRequest

type TypesRequest struct {
}

TypesRequest is the request for getting the types exposed by the rpc object

type TypesResponse

type TypesResponse struct {
	Types map[InterfaceSpec][]string
}

TypesResponse is the response for returning the types exposed by the rpc object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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