Documentation ¶
Index ¶
- Constants
- func Do(rn *Run, src ExeSource, ctrl Control, data chan interface{})
- func PipeConn() (conn1, conn2 io.ReadWriteCloser)
- func Serve(nodeID string, ctrl Control, conn io.ReadWriteCloser) error
- func StdioConn() io.ReadWriteCloser
- type Child
- type Control
- type Direction
- type Download
- type Error
- type ErrorFactory
- type ExeName
- type ExeSource
- type Feedback
- type FileData
- type Flow
- type Flower
- type Local
- type LogEntry
- type MessageFilter
- type Netns
- type Node
- type Packet
- type PacketClient
- type PacketFlag
- type PacketHeader
- type PacketIO
- type PacketInfo
- type PacketSenders
- type PacketServer
- type Parallel
- type ResultStream
- type Run
- type Runners
- type SSH
- type Schedule
- type Seq
- type Serial
- type Sleep
- type Stream
- type StreamClient
- type StreamIO
- type StreamInfo
- type StreamServer
- type Streamers
- type System
- type Transfer
- type Unresponsive
- type Upload
Constants ¶
const RootNodeID = "-"
RootNodeID is the ID used for the root node in node.Do.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do runs a Run tree in an in-process "root" node, and sends data items back on the given channel. The item types that may be sent include StreamInfo, StreamIO, PacketInfo, PacketIO, FileData, LogEntry and Error.
Do is used by the antler package and executable.
func PipeConn ¶
func PipeConn() (conn1, conn2 io.ReadWriteCloser)
PipeConn returns a pair of ReadWriteClosers connected by two Pipes, one each direction.
func Serve ¶
func Serve(nodeID string, ctrl Control, conn io.ReadWriteCloser) error
Serve runs a node whose parent is connected using the given conn. This is used by the standalone node executable.
An error is returned if there was a failure when serving the connection, or the node was explicitly canceled. Serve closes the conn when complete.
func StdioConn ¶
func StdioConn() io.ReadWriteCloser
StdioConn is a ReadWriteCloser used for stdio. On Close, only stdout is closed.
Types ¶
type Child ¶
type Child struct { // Run is the Run to execute on Node. Run // Node is the node to execute Run on. It must be a valid, nonzero value. Node Node }
Child is a Run to execute on a child Node.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control is used to send control signals to nodes.
type Download ¶
type Download struct {
Transfer
}
Download is a stream transfer from server to client.
type Error ¶
type Error struct { Time time.Time // the node time that the error occurred NodeID string // the node ID Tag string // a string for error categorization Message string // the error text }
Error represents an unrecoverable error that occurred on a node.
type ErrorFactory ¶
type ErrorFactory struct {
// contains filtered or unexported fields
}
ErrorFactory provides methods to create and return Errors.
func (ErrorFactory) NewError ¶
func (f ErrorFactory) NewError(message string) Error
NewError returns a new Error with the given message.
func (ErrorFactory) NewErrore ¶
func (f ErrorFactory) NewErrore(err error) Error
NewErrore returns an Error from the given error. If the given error is already an Error, the existing error is returned.
func (ErrorFactory) NewErrorf ¶
func (f ErrorFactory) NewErrorf(format string, a ...interface{}) Error
NewErrorf returns an Error with its Message formatted with prinf style args.
type ExeName ¶
type ExeName string
ExeName represents an antler node executable name.
func PlatformExeName ¶
PlatformExeName returns an ExeName for the given platform (e.g. linux-amd64).
type ExeSource ¶
type ExeSource interface { // Reader returns a ReadCloser for the given platform's node executable. Reader(platform string) (io.ReadCloser, error) // Size returns the size of the given platform's node executable. Size(platform string) (int64, error) // Platforms returns the platforms for which executables are available. Platforms() ([]string, error) }
An ExeSource provides contents and metadata for node executables.
type Feedback ¶
type Feedback map[string]interface{}
Feedback contains key/value pairs, which are returned by runners for use by subsequent runners, and are stored in the result Data. Values must be supported by gob.
type Flower ¶
type Flower interface {
Flow() Flow
}
A Flower wraps the Flow method, to return a Flow associated with the implementation.
type Local ¶
type Local struct { }
Local is a launcher used to start a node as a locally executed process.
type LogEntry ¶
type LogEntry struct { Time time.Time // the time of the LogEntry, per the node's clock NodeID string // the ID of the node that created the LogEntry Tag string // tags the LogEntry for categorization Text string // the text message for the LogEntry }
LogEntry represents one log entry.
type MessageFilter ¶
type MessageFilter struct { // File is a valid glob pattern of FileData names to accept. File []string // Log indicates whether to accept (true) or reject (false) LogEntry's. Log bool // Flows to accept. Flow []Flow }
MessageFilter selects messages based on some simple type and field criteria.
type Netns ¶
type Netns struct { // Name is the name of the namespace. If set, this namespace will either be // created or used, depending on the value of the Create field. Name string // Create indicates whether to create a namespace (true) or use an existing // one (false). If Create is true with no Name set, the Node ID will be used // as the network namespace name. Create bool }
Netns represents the Linux network namespace configuration to use when launching a Node (man ip-netns(8)).
type Node ¶
type Node struct { ID string // identifies the Node Platform string // the Node's platform (e.g. linux-amd64) Launcher launchers // union of available launchers Netns Netns // parameters for Linux network namespaces }
Node represents the information needed to launch a node. It must stay a value object with no pointer fields, so Nodes may be compared and used as map keys.
The zero value for Node is used for the parent Node.
type Packet ¶
type Packet struct { PacketHeader // Len is the total length of the packet, in bytes, including the header. Len int // contains filtered or unexported fields }
Packet represents a Packet sent in either direction between a PacketClient and PacketServer. Only the header is included in the body of the Packet. Padding is added to reach the Packet Length.
type PacketClient ¶
type PacketClient struct { // Addr is the dial address, as specified to the address parameter in // net.Dial (e.g. "addr:port"). Addr string // Protocol is the protocol to use (udp, udp4 or udp6). Protocol string // Flow is the flow identifier for traffic between the client and server. Flow Flow // MaxPacketSize is the maximum size of a received packet. MaxPacketSize int Sender []PacketSenders }
PacketClient is the client used for packet oriented protocols.
type PacketFlag ¶
type PacketFlag byte
PacketFlag represents the flag bits on a packet.
const ( // FlagEcho indicates that the packet requests an echo. FlagEcho PacketFlag = 1 << iota // FlagReply indicates that the packet is a reply to an echo request. FlagReply )
type PacketHeader ¶
type PacketHeader struct { // Flag contains the packet flags. Flag PacketFlag // Seq is the sequence number assigned by the client. Seq Seq // Flow is the flow identifier, and corresponds to a client and server pair. Flow Flow }
PacketHeader represents the header of the packet.
func (*PacketHeader) Len ¶
func (p *PacketHeader) Len() int
Len returns the length of the header, in bytes.
type PacketIO ¶
type PacketIO struct { // Packet is the packet. Packet // T is the node-relative time this PacketIO was recorded. T metric.RelativeTime // Sent is true for a sent packet, and false for received. Sent bool }
PacketIO is a time series data point that records packet send and receive times.
type PacketInfo ¶
type PacketInfo struct { // Tinit is the base time for the flow's RelativeTime values. Tinit time.Time // Flow is the flow identifier. Flow Flow // Server indicates if this is from the server (true) or client (false). Server bool }
PacketInfo contains information for a packet flow.
func (PacketInfo) String ¶
func (p PacketInfo) String() string
func (PacketInfo) Time ¶
func (p PacketInfo) Time(r metric.RelativeTime) time.Time
Time returns an absolute from a node-relative time.
type PacketSenders ¶
type PacketSenders struct {
Unresponsive *Unresponsive
}
PacketSenders is the union of available packetSender implementations.
type PacketServer ¶
type PacketServer struct { // ListenAddr is the listen address, as specified to the address parameter // in net.ListenPacket (e.g. ":port" or "addr:port"). ListenAddr string // Protocol is the protocol to use (udp, udp4 or udp6). Protocol string // MaxPacketSize is the maximum size of a received packet. MaxPacketSize int // contains filtered or unexported fields }
PacketServer is the server used for packet oriented protocols.
func (*PacketServer) Cancel ¶
func (s *PacketServer) Cancel(rec *recorder) error
Cancel implements canceler
type ResultStream ¶
type ResultStream struct { // Include accepts messages to stream. Include *MessageFilter // Exclude rejects messages to stream, and buffers them instead. Exclude *MessageFilter }
ResultStream selects messages for either streaming or buffering.
type Run ¶
type Run struct { // Serial lists Runs to be executed sequentially Serial Serial // Parallel lists Runs to be executed concurrently Parallel Parallel // Schedule lists Runs to be executed on a schedule. Schedule *Schedule // Child is a Run to be executed on a child Node Child *Child // Runners is a union of the available runner implementations. // // NOTE: In the future, this may be an interface field, if CUE can be made // to choose a concrete type without using a field for each runner. Runners }
Run represents the information needed to coordinate the execution of runners. Using the Serial, Parallel and Child fields, Runs may be arranged in a tree for sequential, concurrent and child node execution.
Run must be created with valid constraints, i.e. each Run must have exactly one of Serial, Parallel, Child or a Runners field set. Run is not safe for concurrent use, though Parallel Runs execute safely, concurrently.
type Runners ¶
type Runners struct { ResultStream *ResultStream Setup *setup Sleep *Sleep System *System StreamClient *StreamClient StreamServer *StreamServer PacketServer *PacketServer PacketClient *PacketClient }
Runners is a union of the available runner implementations. Only one of the runners may be non-nil.
type SSH ¶
type SSH struct {
Destination string // ssh destination (man ssh(1))
}
SSH is a launcher used to start an Antler node remotely via ssh.
type Schedule ¶
type Schedule struct { // Wait lists the wait Durations to use. If Random is false, the chosen // Durations cycle repeatedly through Wait. Wait []metric.Duration // WaitFirst, if true, indicates to wait before the first Run as well. WaitFirst bool // Random, if true, indicates to select wait times from Wait randomly. // Otherwise, wait times are taken from Wait sequentially. Random bool // Sequential, if true, indicates to run the Runs in serial. Sequential bool // Run lists the Runs. Run []Run // contains filtered or unexported fields }
Schedule lists Runs to be executed with wait times between each Run.
type Sleep ¶
Sleep is a runner that sleeps for the given Duration, or until canceled.
func (*Sleep) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Stream ¶
type Stream struct { // Flow is the Stream's flow identifier. Flow Flow // Direction is the client to server sense. Direction Direction // CCA is the sender's Congestion Control Algorithm. CCA string }
Stream represents one direction of a stream oriented flow.
func (Stream) Info ¶
func (s Stream) Info(server bool) StreamInfo
Info returns StreamInfo for this Stream.
type StreamClient ¶
type StreamClient struct { // Addr is the dial address, as specified to the address parameter in // net.Dial (e.g. "addr:port"). Addr string // AddrKey is a key used to obtain the dial address from the incoming // Feedback, if Addr is not specified. AddrKey string // Protocol is the protocol to use (tcp, tcp4 or tcp6). Protocol string Streamers }
StreamClient is the client used for stream oriented protocols.
type StreamIO ¶
type StreamIO struct { // Flow is the flow that this StreamIO is for. Flow Flow // T is the relative time this StreamIO was recorded. T metric.RelativeTime // Total is the total number of sent or received bytes. Total metric.Bytes // Sent is true for sent bytes, and false for received. Sent bool }
StreamIO is a time series data point that records the progress of a stream as measured after read or write calls.
type StreamInfo ¶
type StreamInfo struct { // Tinit is the base time for the flow's RelativeTime values. Tinit time.Time Stream // Server indicates if this is from the server (true) or client (false). Server bool }
StreamInfo contains information for a stream flow.
func (StreamInfo) String ¶
func (s StreamInfo) String() string
func (StreamInfo) Time ¶
func (s StreamInfo) Time(r metric.RelativeTime) time.Time
Time returns an absolute from a node-relative time.
type StreamServer ¶
type StreamServer struct { // ListenAddr is the listen address, as specified to the address parameter // in net.Listen (e.g. ":port" or "addr:port"). ListenAddr string // ListenAddrKey is the key used in the returned Feedback for the listen // address, obtained using Listen.Addr.String(). If empty, the listen // address will not be included in the Feedback. ListenAddrKey string // Protocol is the protocol to use (tcp, tcp4 or tcp6). Protocol string // contains filtered or unexported fields }
StreamServer is the server used for stream oriented protocols.
func (*StreamServer) Cancel ¶
func (s *StreamServer) Cancel(rec *recorder) error
Cancel implements canceler
type System ¶
type System struct { // Command is the command to run. The string is split into command name and // arguments using space as a delimiter, with no support for escaping. If // spaces are needed in arguments, use the Args field instead, or in // addition to Command. Command string // Args is a slice of arguments for the command. If Command is empty, then // Args[0] is the command name, otherwise the Args slice is appended to the // slice obtained by splitting Command. Args []string // Background indicates whether to run this command in the background (true) // or foreground (false). If true, Run will return as soon as the command is // started, and with an error if it could not be started and IgnoreErrors is // false. The Context will be cancelled after the rest of the Run tree is // complete, at which time the process will be killed, and the node will // wait for it to complete. Background bool // IgnoreErrors indicates whether to discard any errors (true) or not // (false). IgnoreErrors bool // Stdout selects the treatment for stdout. If empty, stdout is gathered and // emitted to the log as a single line when the command completes. If // "stream", stdout is emitted to the log a line at a time. If "quiet", // stdout is discarded. Otherwise, stdout is written to a file of the given // name. Stdout string // Stderr selects the treatment for stderr, with the same semantics as for // Stdout. Stderr string // Kill indicates whether to kill the process on cancellation (true) or // signal it with an interrupt (false). Kill bool // contains filtered or unexported fields }
System executes a system command.
type Transfer ¶
type Transfer struct { // Duration is the length of time after which the sender stops writing. Duration metric.Duration // Length is the number of bytes after which the sender stops writing. Length metric.Bytes // SampleIOInterval is the minimum time between IO samples. Zero means a // sample will be recorded for every read and write. SampleIOInterval metric.Duration // BufLen is the size of the buffer used to read and write from the conn. BufLen int Stream }
Transfer contains the parameters for an Upload or Download.
type Unresponsive ¶
type Unresponsive struct { // Wait lists the wait times between packets, which are cycled through // either sequentially or randomly (according to RandomWait) until all // packets are sent. Wait []metric.Duration // WaitFirst, if true, indicates to wait before sending the first packet as // well. WaitFirst bool // RandomWait, if true, indicates to use random wait times from the list. // Otherwise, the wait times are taken from Wait sequentially. RandomWait bool // Length lists the lengths of the packets, which are cycled through either // sequentially or randomly (according to RandomLength) until all packets // are sent. Length []int // RandomLength, if true, indicates to use random lengths from the list. // Otherwise, the lengths are taken from Length sequentially. RandomLength bool // Duration is how long to send packets. Duration metric.Duration // Echo, if true, requests mirrored replies from the server. Echo bool // contains filtered or unexported fields }
Unresponsive sends packets on a schedule without regard to any congestion signals.