xfer

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppPort is the default port that the app will use for its HTTP server.
	// The app publishes the API and user interface, and receives reports from
	// probes, on this port.
	AppPort = 4040

	// ScopeProbeIDHeader is the header we use to carry the probe's unique ID. The
	// ID is currently set to the a random string on probe startup.
	ScopeProbeIDHeader = "X-Scope-Probe-ID"
)

Variables

View Source
var ErrInvalidMessage = fmt.Errorf("Invalid Message")

ErrInvalidMessage is the error returned when the on-wire message is unexpected.

Functions

This section is empty.

Types

type ControlHandler

type ControlHandler interface {
	Handle(req Request, res *Response) error
}

ControlHandler is interface used in the app and the probe to represent a control RPC.

type ControlHandlerFunc

type ControlHandlerFunc func(Request) Response

ControlHandlerFunc is a adapter (ala golang's http RequestHandlerFunc) for ControlHandler

func (ControlHandlerFunc) Handle

func (c ControlHandlerFunc) Handle(req Request, res *Response) error

Handle is an adapter method to make ControlHandlers exposable via golang rpc

type Details

type Details struct {
	ID       string `json:"id"`
	Version  string `json:"version"`
	Hostname string `json:"hostname"`
}

Details are some generic details that can be fetched from /api

type JSONWebsocketCodec

type JSONWebsocketCodec struct {
	sync.Mutex
	// contains filtered or unexported fields
}

JSONWebsocketCodec is golang rpc compatible Server and Client Codec that transmits and receives RPC messages over a websocker, as JSON.

func NewJSONWebsocketCodec

func NewJSONWebsocketCodec(conn *websocket.Conn) *JSONWebsocketCodec

NewJSONWebsocketCodec makes a new JSONWebsocketCodec

func (*JSONWebsocketCodec) Close

func (j *JSONWebsocketCodec) Close() error

Close implements rpc.ClientCodec and rpc.ServerCodec

func (*JSONWebsocketCodec) ReadRequestBody

func (j *JSONWebsocketCodec) ReadRequestBody(v interface{}) error

ReadRequestBody implements rpc.ServerCodec

func (*JSONWebsocketCodec) ReadRequestHeader

func (j *JSONWebsocketCodec) ReadRequestHeader(r *rpc.Request) error

ReadRequestHeader implements rpc.ServerCodec

func (*JSONWebsocketCodec) ReadResponseBody

func (j *JSONWebsocketCodec) ReadResponseBody(v interface{}) error

ReadResponseBody implements rpc.ClientCodec

func (*JSONWebsocketCodec) ReadResponseHeader

func (j *JSONWebsocketCodec) ReadResponseHeader(r *rpc.Response) error

ReadResponseHeader implements rpc.ClientCodec

func (*JSONWebsocketCodec) WaitForReadError

func (j *JSONWebsocketCodec) WaitForReadError()

WaitForReadError blocks until any read on this codec returns an error. This is useful to know when the server has disconnected from the client.

func (*JSONWebsocketCodec) WriteRequest

func (j *JSONWebsocketCodec) WriteRequest(r *rpc.Request, v interface{}) error

WriteRequest implements rpc.ClientCodec

func (*JSONWebsocketCodec) WriteResponse

func (j *JSONWebsocketCodec) WriteResponse(r *rpc.Response, v interface{}) error

WriteResponse implements rpc.ServerCodec

type Message

type Message struct {
	Request  *rpc.Request
	Response *rpc.Response
	Value    interface{}
}

Message is the unions of Request, Response and arbitrary Value.

type Pipe

type Pipe interface {
	Ends() (io.ReadWriter, io.ReadWriter)
	CopyToWebsocket(io.ReadWriter, *websocket.Conn) error

	Close() error
	Closed() bool
	OnClose(func())
}

Pipe is a bi-directional channel from someone thing in the probe to the UI.

func NewPipe

func NewPipe() Pipe

NewPipe makes a new... pipe.

type Request

type Request struct {
	AppID   string
	NodeID  string
	Control string
}

Request is the UI -> App -> Probe message type for control RPCs

type Response

type Response struct {
	Value  interface{} `json:"value,omitempty"`
	Error  string      `json:"error,omitempty"`
	Pipe   string      `json:"pipe,omitempty"`
	RawTTY bool        `json:"raw_tty,omitempty"`
}

Response is the Probe -> App -> UI message type for the control RPCs.

func ResponseError

func ResponseError(err error) Response

ResponseError creates a new Response with the given error.

func ResponseErrorf

func ResponseErrorf(format string, a ...interface{}) Response

ResponseErrorf creates a new Response with the given formatted error string.

Jump to

Keyboard shortcuts

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