xfer

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2015 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ScopeProbeIDHeader = "X-Scope-Probe-ID"

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.

Variables

View Source
var (
	// 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
)

Functions

This section is empty.

Types

type AppClient added in v0.10.0

type AppClient interface {
	Details() (Details, error)
	ControlConnection(handler ControlHandler)
	Stop()
}

AppClient is a client to an app for dealing with controls.

func NewAppClient added in v0.10.0

func NewAppClient(pc ProbeConfig, hostname, target string) (AppClient, error)

NewAppClient makes a new AppClient.

type BackgroundPublisher added in v0.7.0

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

BackgroundPublisher is a publisher which does the publish asynchronously. It will only do one publish at once; if there is an ongoing publish, concurrent publishes are dropped.

func NewBackgroundPublisher added in v0.7.0

func NewBackgroundPublisher(p Publisher) *BackgroundPublisher

NewBackgroundPublisher creates a new BackgroundPublisher with the given publisher

func (*BackgroundPublisher) Publish added in v0.7.0

func (bp *BackgroundPublisher) Publish(r io.Reader) error

Publish implements Publisher

func (*BackgroundPublisher) Stop added in v0.7.0

func (bp *BackgroundPublisher) Stop()

Stop implements Publisher

type ClientFactory added in v0.10.0

type ClientFactory func(ProbeConfig, string, string) (AppClient, error)

ClientFactory is a thing thats makes AppClients

type ControlHandler added in v0.10.0

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 added in v0.10.0

type ControlHandlerFunc func(Request) Response

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

func (ControlHandlerFunc) Handle added in v0.10.0

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

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

type Details added in v0.10.0

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

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

type HTTPPublisher added in v0.6.0

type HTTPPublisher struct {
	ProbeConfig
	// contains filtered or unexported fields
}

HTTPPublisher publishes buffers by POST to a fixed endpoint.

func NewHTTPPublisher added in v0.6.0

func NewHTTPPublisher(hostname, target, token, probeID string, insecure bool) (string, *HTTPPublisher, error)

NewHTTPPublisher returns an HTTPPublisher ready for use.

func (HTTPPublisher) Publish added in v0.6.0

func (p HTTPPublisher) Publish(r io.Reader) error

Publish publishes the report to the URL.

func (*HTTPPublisher) Stop added in v0.7.0

func (p *HTTPPublisher) Stop()

Stop implements Publisher

func (HTTPPublisher) String added in v0.7.0

func (p HTTPPublisher) String() string

type JSONWebsocketCodec added in v0.10.0

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 added in v0.10.0

func NewJSONWebsocketCodec(conn *websocket.Conn) *JSONWebsocketCodec

NewJSONWebsocketCodec makes a new JSONWebsocketCodec

func (*JSONWebsocketCodec) Close added in v0.10.0

func (j *JSONWebsocketCodec) Close() error

Close implements rpc.ClientCodec and rpc.ServerCodec

func (*JSONWebsocketCodec) ReadRequestBody added in v0.10.0

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

ReadRequestBody implements rpc.ServerCodec

func (*JSONWebsocketCodec) ReadRequestHeader added in v0.10.0

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

ReadRequestHeader implements rpc.ServerCodec

func (*JSONWebsocketCodec) ReadResponseBody added in v0.10.0

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

ReadResponseBody implements rpc.ClientCodec

func (*JSONWebsocketCodec) ReadResponseHeader added in v0.10.0

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

ReadResponseHeader implements rpc.ClientCodec

func (*JSONWebsocketCodec) WaitForReadError added in v0.10.0

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 added in v0.10.0

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

WriteRequest implements rpc.ClientCodec

func (*JSONWebsocketCodec) WriteResponse added in v0.10.0

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

WriteResponse implements rpc.ServerCodec

type MultiAppClient added in v0.10.0

type MultiAppClient interface {
	Set(hostname string, endpoints []string)
	Stop()
}

MultiAppClient maintains a set of upstream apps, and ensures we have an AppClient for each one.

func NewMultiAppClient added in v0.10.0

func NewMultiAppClient(pc ProbeConfig, handler ControlHandler, clientFactory ClientFactory) MultiAppClient

NewMultiAppClient creates a new MultiAppClient.

type MultiPublisher added in v0.6.0

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

MultiPublisher implements publisher over a collection of heterogeneous targets. See documentation of each method to understand the semantics.

func NewMultiPublisher added in v0.6.0

func NewMultiPublisher(factory func(hostname, endpoint string) (string, Publisher, error)) *MultiPublisher

NewMultiPublisher returns a new MultiPublisher ready for use.

func (*MultiPublisher) Delete added in v0.8.0

func (p *MultiPublisher) Delete(target string)

Delete removes all endpoints that match the given target.

func (*MultiPublisher) Publish added in v0.6.0

func (p *MultiPublisher) Publish(r io.Reader) error

Publish implements Publisher by publishing the reader to all of the underlying publishers sequentially. To do that, it needs to drain the reader, and recreate new readers for each publisher. Note that it will publish to one endpoint for each unique ID. Failed publishes don't count.

func (*MultiPublisher) Set added in v0.8.0

func (p *MultiPublisher) Set(target string, endpoints []string)

Set declares that the target (DNS name) resolves to the provided endpoints (IPs), and that we want to publish to each of those endpoints. Set replaces any existing publishers to the given target. Set invokes the factory method to convert each endpoint to a publisher, and to get the remote receiver's unique ID.

func (*MultiPublisher) Stop added in v0.7.0

func (p *MultiPublisher) Stop()

Stop invokes stop on all underlying publishers and removes them.

type ProbeConfig added in v0.10.0

type ProbeConfig struct {
	Token    string
	ProbeID  string
	Insecure bool
}

ProbeConfig contains all the info needed for a probe to do HTTP requests

type Publisher

type Publisher interface {
	Publish(io.Reader) error
	Stop()
}

Publisher is something which can send a stream of data somewhere, probably to a remote collector.

type ReportPublisher added in v0.7.0

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

A ReportPublisher uses a buffer pool to serialise reports, which it then passes to a publisher

func NewReportPublisher added in v0.7.0

func NewReportPublisher(publisher Publisher) *ReportPublisher

NewReportPublisher creates a new report publisher

func (*ReportPublisher) Publish added in v0.7.0

func (p *ReportPublisher) Publish(r report.Report) error

Publish serialises and compresses a report, then passes it to a publisher

type Request added in v0.10.0

type Request struct {
	ID      int64
	NodeID  string
	Control string
}

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

type Resolver added in v0.10.0

type Resolver interface {
	Stop()
}

Resolver is a thing that can be stopped...

func NewStaticResolver added in v0.10.0

func NewStaticResolver(targets []string, setters ...setter) Resolver

NewStaticResolver periodically resolves the targets, and calls the set function with all the resolved IPs. It explictiy supports targets which resolve to multiple IPs.

type Response added in v0.10.0

type Response struct {
	ID    int64
	Value interface{}
	Error string
}

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

func ResponseError added in v0.10.0

func ResponseError(err error) Response

ResponseError creates a new Response with the given error.

func ResponseErrorf added in v0.10.0

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