Documentation ¶
Index ¶
- Constants
- Variables
- func IsExpectedWSCloseError(err error) bool
- type ControlHandler
- type ControlHandlerFunc
- type Details
- type JSONWebsocketCodec
- func (j *JSONWebsocketCodec) Close() error
- func (j *JSONWebsocketCodec) ReadRequestBody(v interface{}) error
- func (j *JSONWebsocketCodec) ReadRequestHeader(r *rpc.Request) error
- func (j *JSONWebsocketCodec) ReadResponseBody(v interface{}) error
- func (j *JSONWebsocketCodec) ReadResponseHeader(r *rpc.Response) error
- func (j *JSONWebsocketCodec) WaitForReadError() error
- func (j *JSONWebsocketCodec) WriteRequest(r *rpc.Request, v interface{}) error
- func (j *JSONWebsocketCodec) WriteResponse(r *rpc.Response, v interface{}) error
- type Message
- type NewVersionInfo
- type Pipe
- type PluginSpec
- type PluginSpecs
- func (n PluginSpecs) Add(specs ...PluginSpec) PluginSpecs
- func (n *PluginSpecs) CodecDecodeSelf(decoder *codec.Decoder)
- func (n *PluginSpecs) CodecEncodeSelf(encoder *codec.Encoder)
- func (n PluginSpecs) Copy() PluginSpecs
- func (n PluginSpecs) DeepEqual(i interface{}) bool
- func (n PluginSpecs) ForEach(f func(PluginSpec))
- func (n PluginSpecs) Keys() []string
- func (n PluginSpecs) Lookup(key string) (PluginSpec, bool)
- func (PluginSpecs) MarshalJSON() ([]byte, error)
- func (n PluginSpecs) Merge(other PluginSpecs) PluginSpecs
- func (n PluginSpecs) Size() int
- func (n PluginSpecs) String() string
- func (*PluginSpecs) UnmarshalJSON(b []byte) error
- type PluginSpecsByID
- type Request
- type Response
- type WSDialer
- type Websocket
Constants ¶
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" // ScopeProbeVersionHeader is the header we use to carry the probe's version. ScopeProbeVersionHeader = "X-Scope-Probe-Version" )
const HistoricReportsCapability = "historic_reports"
HistoricReportsCapability indicates whether reports older than the current time (-app.window) can be retrieved.
Variables ¶
var EmptyPluginSpecs = PluginSpecs{ps.NewMap()}
EmptyPluginSpecs is the empty set of plugin specs.
var ErrInvalidMessage = fmt.Errorf("Invalid Message")
ErrInvalidMessage is the error returned when the on-wire message is unexpected.
Functions ¶
func IsExpectedWSCloseError ¶ added in v0.13.0
IsExpectedWSCloseError returns boolean indicating whether the error is a clean disconnection.
Types ¶
type ControlHandler ¶
ControlHandler is interface used in the app and the probe to represent a control RPC.
type ControlHandlerFunc ¶
ControlHandlerFunc is a adapter (ala golang's http RequestHandlerFunc) for ControlHandler
func ResizeTTYControlWrapper ¶ added in v1.0.0
func ResizeTTYControlWrapper(next func(pipeID string, height, width uint) Response) ControlHandlerFunc
ResizeTTYControlWrapper extracts the arguments needed by the resize tty control handler
type Details ¶
type Details struct { ID string `json:"id"` Version string `json:"version"` Hostname string `json:"hostname"` Plugins PluginSpecs `json:"plugins,omitempty"` Capabilities map[string]bool `json:"capabilities,omitempty"` NewVersion *NewVersionInfo `json:"newVersion,omitempty"` }
Details are some generic details that can be fetched from /api
type JSONWebsocketCodec ¶
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) *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() error
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 NewVersionInfo ¶ added in v0.15.0
type NewVersionInfo struct { Version string `json:"version"` DownloadURL string `json:"downloadUrl"` }
NewVersionInfo is the struct exposed in /api when there is a new version of Scope available.
type Pipe ¶
type Pipe interface { Ends() (io.ReadWriter, io.ReadWriter) CopyToWebsocket(io.ReadWriter, Websocket) error Close() error Closed() bool OnClose(func()) }
Pipe is a bi-directional channel from something in the probe to the UI.
func NewPipeFromEnds ¶ added in v0.14.0
func NewPipeFromEnds(local io.ReadWriter, remote io.ReadWriter) Pipe
NewPipeFromEnds makes a new pipe specifying its ends
type PluginSpec ¶ added in v0.14.0
type PluginSpec struct { ID string `json:"id"` // Label is a human-readable name of the plugin Label string `json:"label"` Description string `json:"description,omitempty"` // Interfaces is a list of things this plugin can be used for (e.g. "reporter") Interfaces []string `json:"interfaces"` APIVersion string `json:"api_version,omitempty"` Status string `json:"status,omitempty"` }
PluginSpec is shared between the Probe, App, and UI. It is the plugin's self-proclaimed description.
type PluginSpecs ¶ added in v0.14.0
type PluginSpecs struct {
// contains filtered or unexported fields
}
PluginSpecs is a set of plugin specs keyed on ID. Clients must use the Add method to add plugin specs
func MakePluginSpecs ¶ added in v0.14.0
func MakePluginSpecs(specs ...PluginSpec) PluginSpecs
MakePluginSpecs makes a new PluginSpecs with the given plugin specs.
func (PluginSpecs) Add ¶ added in v0.14.0
func (n PluginSpecs) Add(specs ...PluginSpec) PluginSpecs
Add adds the specs to the PluginSpecs. Add is the only valid way to grow a PluginSpecs. Add returns the PluginSpecs to enable chaining.
func (*PluginSpecs) CodecDecodeSelf ¶ added in v0.14.0
func (n *PluginSpecs) CodecDecodeSelf(decoder *codec.Decoder)
CodecDecodeSelf implements codec.Selfer
func (*PluginSpecs) CodecEncodeSelf ¶ added in v0.14.0
func (n *PluginSpecs) CodecEncodeSelf(encoder *codec.Encoder)
CodecEncodeSelf implements codec.Selfer
func (PluginSpecs) DeepEqual ¶ added in v0.14.0
func (n PluginSpecs) DeepEqual(i interface{}) bool
DeepEqual tests equality with other PluginSpecss
func (PluginSpecs) ForEach ¶ added in v0.14.0
func (n PluginSpecs) ForEach(f func(PluginSpec))
ForEach executes f for each spec in the set. Nodes are traversed in sorted order.
func (PluginSpecs) Keys ¶ added in v0.14.0
func (n PluginSpecs) Keys() []string
Keys is a list of all the keys in this set.
func (PluginSpecs) Lookup ¶ added in v0.14.0
func (n PluginSpecs) Lookup(key string) (PluginSpec, bool)
Lookup the spec by 'key'
func (PluginSpecs) MarshalJSON ¶ added in v0.14.0
func (PluginSpecs) MarshalJSON() ([]byte, error)
MarshalJSON shouldn't be used, use CodecEncodeSelf instead
func (PluginSpecs) Merge ¶ added in v0.14.0
func (n PluginSpecs) Merge(other PluginSpecs) PluginSpecs
Merge combines the two PluginSpecss and returns a new result.
func (PluginSpecs) Size ¶ added in v0.14.0
func (n PluginSpecs) Size() int
Size is the number of specs in the set
func (PluginSpecs) String ¶ added in v0.14.0
func (n PluginSpecs) String() string
func (*PluginSpecs) UnmarshalJSON ¶ added in v0.14.0
func (*PluginSpecs) UnmarshalJSON(b []byte) error
UnmarshalJSON shouldn't be used, use CodecDecodeSelf instead
type PluginSpecsByID ¶ added in v0.14.0
type PluginSpecsByID []PluginSpec
PluginSpecsByID implements sort.Interface, so we can sort the specs by the ID field.
func (PluginSpecsByID) Len ¶ added in v0.14.0
func (p PluginSpecsByID) Len() int
Len is part of sort.Interface.
func (PluginSpecsByID) Less ¶ added in v0.14.0
func (p PluginSpecsByID) Less(i, j int) bool
Less is part of sort.Interface.
func (PluginSpecsByID) Swap ¶ added in v0.14.0
func (p PluginSpecsByID) Swap(i, j int)
Swap is part of sort.Interface.
type Request ¶
type Request struct { AppID string // filled in by the probe on receiving this request NodeID string Control string ControlArgs map[string]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 specific fields Pipe string `json:"pipe,omitempty"` RawTTY bool `json:"raw_tty,omitempty"` ResizeTTYControl string `json:"resize_tty_control,omitempty"` // Remove specific fields RemovedNode string `json:"removedNode,omitempty"` // Set if node was removed }
Response is the Probe -> App -> UI message type for the control RPCs.
func ResponseError ¶
ResponseError creates a new Response with the given error.
func ResponseErrorf ¶
ResponseErrorf creates a new Response with the given formatted error string.
type WSDialer ¶ added in v0.13.0
type WSDialer interface {
Dial(urlStr string, requestHeader http.Header) (*websocket.Conn, *http.Response, error)
}
WSDialer can dial a new websocket
type Websocket ¶ added in v0.13.0
type Websocket interface { ReadMessage() (messageType int, p []byte, err error) WriteMessage(messageType int, data []byte) error ReadJSON(v interface{}) error WriteJSON(v interface{}) error Close() error }
Websocket exposes the bits of *websocket.Conn we actually use.
func DialWS ¶ added in v0.13.0
func DialWS(d WSDialer, urlStr string, requestHeader http.Header) (Websocket, *http.Response, error)
DialWS creates a new client connection. Use requestHeader to specify the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie). Use the response.Header to get the selected subprotocol (Sec-WebSocket-Protocol) and cookies (Set-Cookie).