Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
// The address on which the queue listens.
QueueAddr, _ = ParseAddr("127.0.0.1:9000")
// The interval at which to send keep-alive messages on idle connections.
// This setting shall be set before any Conn has been created, and shall not
// be altered afterwards.
KeepAliveInterval = 30 * time.Second
// Initial interval between dial tries. After each failed attempt, the
// interval is doubled, up to MaxRetryInterval.
InitialRetryInterval = 32 * time.Millisecond
// Maximum time interval between dial tries.
MaxRetryInterval = 5 * time.Minute
)
Global configuration
var Components = make(map[string]ComponentInfo)
The global Components map contains all registered component types.
Functions ¶
func LocalAddr ¶
LocalAddr returns a random local unix address located in the system's temporary directory.
func ParseAddr ¶
ParseAddr parses an address description into an address. If the description starts with "unix:", the result will be a Unix domain socket address with the path being the rest of the description string. Otherwise, the result will be a TCP address represented by the whole description string.
Types ¶
type Component ¶
type Component interface { // Parse the command line arguments given by args and configure the // component. Setup(fs *flag.FlagSet, args []string) error // Execute the component. Run() // Shut down the component. Shutdown() }
A Component is meant to be run in its own process, and maybe on a separate machine.
type ComponentInfo ¶
type ComponentInfo struct { // CLI name of the component (must be unique). // This is also the key of the Components map. Name string // Short one-line description that can be shown in the CLI. Description string // Function to create a new component of this type. New func() Component }
A ComponentInfo is a type of component. Each type registers in the global Components map.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a wrapper over net.Conn, reading and writing Messages.
func DialRetry ¶
DialRetry is equivalent to Dial, but it keeps on retrying (with exponential back-off) until the connection is established.
func WrapConn ¶
WrapConn wraps a stream network connection into a Message-oriented connection. The raw conn connection shall not be used by the user anymore.
func (*Conn) Close ¶
Close closes the connection. The receive channel will also be closed. Further sends will cause errors.
type Listener ¶
type Listener struct { // The address on which the listener listens Addr net.Addr // contains filtered or unexported fields }
Listener is a wrapper around net.Listener providing a Message-oriented interface.
type Message ¶
type Message struct { // The message. Message MsgType `json:"message"` // The capacity of the pool. Only for message register-pool. Capacity int `json:"capacity,omitempty"` // The task identifier. Only for messages launch, done and abort. Id string `json:"id,omitempty"` // The task to launch. Only for message launch. Task *Task `json:"task,omitempty"` // The input to feed to the task. Only for message launch. Input string `json:"input,omitempty"` // The result status of the execution. Only for message done. Status Status `json:"status,omitempty"` // The result output of the execution. Only for message done. Output string `json:"output,omitempty"` }
A Message is the basic entity that is sent between components. Messages are serialized to JSON.
type MsgType ¶
type MsgType string
Message type. Components may have internal message types starting with a hyphen.
const ( // Internal message for keeping a connection alive. KeepAliveMsg MsgType = "keep-alive" // Register a sandbox pool. // Pool->Queue RegisterPoolMsg MsgType = "register-pool" // Request execution of a task. // Frontend->Queue, Queue->Pool LaunchMsg MsgType = "launch" // Job done. // Pool->Queue, Queue->Frontend. DoneMsg MsgType = "done" // Abort job. The receiving end shall send a done message with status abort // (or another status if the job has ended meanwhile). // Frontend->Queue, Queue->Pool AbortMsg MsgType = "abort" )
type Status ¶
type Status string
Status of a task execution.
const ( Success Status = "success" // finished, output = stdout Timeout Status = "timeout" // timed out, output = stdout so far Overflow Status = "overflow" // stdout too big, output = capped stdout Abort Status = "abort" // aborted by abort message, no output Crash Status = "crash" // sandbox crashed, output = stdout Error Status = "error" // (maybe temporary) error, output = error message Fatal Status = "fatal" // unrecoverable error (e.g. misformatted task), output = error message )
type Task ¶
type Task struct { // Environment is the name of the root filesystem. Environment string `json:"environment"` // TaskFS is the relative path to the task filesystem. TaskFS string `json:"taskfs"` // Execution limits to be enforced in the sandbox. Limits struct { // Maximum execution time in seconds. Time int `json:"time"` // Total amount of main memory (in megabytes) allocated // to the sandbox VM. Memory int `json:"memory"` // Fraction (in percents) of main memory that can be used as disk space // in a tmpfs. Note that only used disk space is allocated. Disk int `json:"disk"` // Maximum size of the output (in bytes). Output int `json:"output"` } `json:"limits"` }
Task is the description of a task to be run in a sandbox.