Documentation
¶
Overview ¶
Package boruta contains definitions of all interfaces and structs used between the main modules of the Boruta system. Server - service managing Users, Workers, Requests and Jobs. User - a system or a person creating the Requests. Worker - MuxPi with a target device, which executes the Jobs from the Server.
Index ¶
- Constants
- Variables
- type AccessInfo
- type Capabilities
- type Dryad
- type Group
- type Groups
- type JobInfo
- type ListDirection
- type ListFilter
- type ListInfo
- type NotFoundError
- type Priority
- type ReqID
- type ReqInfo
- type ReqState
- type Requests
- type RequestsPaginator
- type SortInfo
- type SortOrder
- type Superviser
- type UserInfo
- type WorkerInfo
- type WorkerState
- type WorkerUUID
- type Workers
- type WorkersPaginator
Constants ¶
const ( // SortOrderAsc means ascending order. This is the default. SortOrderAsc SortOrder = false // SortOrderDesc means descending order. SortOrderDesc SortOrder = true // DirectionForward means that list is traversed in forward direction. This is the default. DirectionForward ListDirection = false // DirectionBackward means that list is traversed in backward direction. DirectionBackward ListDirection = true // MaxPageLimit denotes maximum value that pageInfo.Limit can be. MaxPageLimit = uint16(math.MaxUint16) )
const Version string = "0.2.0"
Version of Boruta.
Variables ¶
var ( // ErrInternalLogicError means that boruta's implementation has detected unexpected behaviour. ErrInternalLogicError = errors.New("Boruta's internal logic error") // ErrWrongSortItem means that unknown item name was provided. ErrWrongSortItem = errors.New("unknown name of item by which list should be sorted") // ErrWrongSortOrder is returned when user provided unknown order. ErrWrongSortOrder = errors.New("unknown sort order (valid: ascending or descending)") // ErrWrongListDirection is returned when user provided unknown order. ErrWrongListDirection = errors.New("unknown direction (valid: forward or backward)") )
Functions ¶
This section is empty.
Types ¶
type AccessInfo ¶
type AccessInfo struct {
// Addr is necessary information to connect to a tunnel to Dryad.
Addr net.Addr
// Key is private RSA key of the job session.
Key rsa.PrivateKey
// Username is a login name for the job session.
Username string
}
AccessInfo contains necessary information to access the Worker.
type Capabilities ¶
Capabilities describe the features provided by the Worker and required by the Request. They are also known as caps.
func (Capabilities) GetWorkerUUID ¶
func (caps Capabilities) GetWorkerUUID() WorkerUUID
GetWorkerUUID returns WorkerUUID stored in caps.
It assumes that "UUID" key is present and should be used only when this fact was verified.
type Dryad ¶
type Dryad interface {
// PutInMaintenance prepares MuxPi for administrative action.
// It blinks LEDs, prints msg on the OLED display, etc.
PutInMaintenance(msg string) (err error)
// Prepare creates appropriate user, generates SSH keypair, installs public key
// so that it can be used for SSH authentication and returns private key.
// It removes current instance of the user, etc.
Prepare(key *ssh.PublicKey) (err error)
// Healthcheck tests Dryad for system state, STM functions and state on MuxPi.
// It may cause Dryad to call SetFail of Worker interface if the problem detected is critical.
Healthcheck() (err error)
}
Dryad is a MuxPi management interface used by Boruta.
type JobInfo ¶
type JobInfo struct {
// WorkerUUID identifies worker that runs the job.
WorkerUUID WorkerUUID
// Timeout after which this Job will be terminated.
Timeout time.Time
}
JobInfo describes the Job.
type ListDirection ¶ added in v0.2.0
type ListDirection bool
ListDirection denotes in which direction collection should be traversed.
func (*ListDirection) MarshalText ¶ added in v0.2.0
func (direction *ListDirection) MarshalText() ([]byte, error)
MarshalText is implementation of encoding.TextMarshaler interface. It is used to properly marshal from structures that contain ListDirection members.
func (ListDirection) String ¶ added in v0.2.0
func (direction ListDirection) String() string
String returns textual representation of ListDirection ("forward" or "backward").
func (*ListDirection) UnmarshalText ¶ added in v0.2.0
func (direction *ListDirection) UnmarshalText(text []byte) error
UnmarshalText is implementation of encoding.TextUnmarshaler interface. It is used to properly unmarshal structures that contain ListDirection members.
type ListFilter ¶
type ListFilter interface {
// Match tells if element matches the filter.
Match(elem interface{}) bool
}
ListFilter is used to filter elements in a collection.
type ListInfo ¶ added in v0.2.0
type ListInfo struct {
// TotalItems contains information how many items in total is in filtered collection.
TotalItems uint64
// RemainingItems contains information how many items are left till the end of colleciton
// (when paginating).
RemainingItems uint64
}
ListInfo contains information about filtered list - how many items are there and how many items are left till the end.
type NotFoundError ¶
type NotFoundError string
NotFoundError is used whenever searched element is missing.
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type Priority ¶
type Priority uint8
Priority is the importance of the Request. Lower - more important.
type ReqInfo ¶
type ReqInfo struct {
ID ReqID
Priority Priority
// Owner is the User who created the Request.
Owner UserInfo
// Deadline is a time after which a Request's State will be set to TIMEOUT
// if it had not been fulfilled.
Deadline time.Time
// ValidAfter is a time before which a Request will not be executed.
ValidAfter time.Time
State ReqState
Job *JobInfo
// Caps are the Worker capabilities required by the Request.
Caps Capabilities
}
ReqInfo describes the Request.
type ReqState ¶
type ReqState string
ReqState denotes state of the Request.
const ( // WAIT - Request is in the Queue waiting for processing. WAIT ReqState = "WAITING" // INPROGRESS - Request has Job with Worker assigned. INPROGRESS ReqState = "IN PROGRESS" // CANCEL - Request has been cancelled by the User. CANCEL ReqState = "CANCELLED" // TIMEOUT - Deadline is past due. TIMEOUT ReqState = "TIMEOUT" // INVALID - Request can no longer be satisfied. INVALID ReqState = "INVALID" // DONE - Request has finished execution. DONE ReqState = "DONE" // FAILED - Worker has failed or has been put into MAINTENANCE state by the Admin. FAILED ReqState = "FAILED" )
type Requests ¶
type Requests interface {
// NewRequest creates a Request with given features and adds it to the Queue.
// It returns ID of the created Request.
NewRequest(caps Capabilities, priority Priority, owner UserInfo,
validAfter time.Time, deadline time.Time) (ReqID, error)
// CloseRequest sets the Request's State to CANCEL (removes from the Queue)
// or DONE (finishes the Job).
CloseRequest(reqID ReqID) error
// UpdateRequest modifies existing request. Request can be modified only
// when it is in WAIT state.
UpdateRequest(reqInfo *ReqInfo) error
// GetRequestInfo returns ReqInfo associated with ReqID.
GetRequestInfo(reqID ReqID) (ReqInfo, error)
// ListRequests returns slice of ReqInfo matching the filter (any request matches if filter
// is empty or nil). Returned requests are sorted by given sorter. Matching requests are
// divided into pages according to paginator and paginator specified page is returned.
// Additional metadata are returned as a pointer to ListInfo.
ListRequests(filter ListFilter, sorter *SortInfo, paginator *RequestsPaginator) ([]ReqInfo,
*ListInfo, error)
// AcquireWorker returns information necessary to access the Worker reserved by the Request
// and prolongs access to it. If the Request is in the WAIT state, call to this function
// will block until the state changes.
// Users should use ProlongAccess() in order to avoid side-effects.
AcquireWorker(reqID ReqID) (AccessInfo, error)
// ProlongAccess sets the Job's Deadline to a predefined time.Duration from the time.Now().
// It can be called multiple times, but is limited.
ProlongAccess(reqID ReqID) error
}
Requests defines an interaction of a user with Requests Queue.
type RequestsPaginator ¶ added in v0.2.0
type RequestsPaginator struct {
// ID sets page border. When direction is set to forward the page will start with first
// request after the ID and contain up to Limit items. If direction is set backward then
// page contains up to Limit items before ID.
ID ReqID
// Direction in which list should be traversed.
Direction ListDirection
// Limit up to how many elements can be stored on one page.
Limit uint16
}
RequestsPaginator contains information to get specific page of listed requests.
type SortInfo ¶ added in v0.2.0
type SortInfo struct {
// Item by which collection should be sorted.
Item string
// Order in which collection should be sorted.
Order SortOrder
}
SortInfo contains information needed to sort collections in Boruta (requests, workers).
type SortOrder ¶ added in v0.2.0
type SortOrder bool
SortOrder denotes in which order (ascending or descending) collection should be sorted.
func (*SortOrder) MarshalText ¶ added in v0.2.0
MarshalText is implementation of encoding.TextMarshaler interface. It is used to properly marshal from structures that contain SortOrder members.
func (SortOrder) String ¶ added in v0.2.0
String returns textual representation of SortOrder ("ascending" or "descending").
func (*SortOrder) UnmarshalText ¶ added in v0.2.0
UnmarshalText is implementation of encoding.TextUnmarshaler interface. It is used to properly unmarshal structures that contain SortOrder members.
type Superviser ¶
type Superviser interface {
// Register adds a new Worker to the system in the MAINTENANCE state.
// Capabilities are set on the Worker and can be changed by subsequent Register calls.
// dryadAddress and sshAddress inform Superviser on address it should use to connect
// using Go RPC and SSH respectively. They should parse to net.TCPAddr.
Register(caps Capabilities, dryadAddress string, sshAddress string) (err error)
// SetFail notifies the Server about the Failure of the Worker.
// It can additionally contain non-empty reason of the failure.
SetFail(uuid WorkerUUID, reason string) (err error)
}
Superviser defines registration and repost actions that can be done by a worker only.
type UserInfo ¶
type UserInfo struct {
// Groups defines workers group that are accessible for user's requests.
Groups Groups
}
UserInfo is a definition of the User or the Admin.
type WorkerInfo ¶
type WorkerInfo struct {
WorkerUUID WorkerUUID
State WorkerState
Groups Groups
Caps Capabilities
}
WorkerInfo describes the Worker.
type WorkerState ¶
type WorkerState string
WorkerState denotes state of the Worker.
const ( // MAINTENANCE - Worker will not be assigned any Jobs. MAINTENANCE WorkerState = "MAINTENANCE" // IDLE - Worker is waiting for the Job. IDLE WorkerState = "IDLE" // RUN - Job is currently being executed on the Worker. RUN WorkerState = "RUNNING" // FAIL - An error occured, reported by the Worker itself or the Server. FAIL WorkerState = "FAILED" // PREPARE - Worker is being prepared to enter IDLE state. PREPARE WorkerState = "PREPARE" // BUSY - Worker is being prepared to enter MAINTENANCE state. BUSY WorkerState = "BUSY" )
type Workers ¶
type Workers interface {
// ListWorkers returns a slice of Workers matching filter (any worker matches if filter is
// empty or nil. The list is sorted according to passed sorter (using default sorting when
// it's nil). Matching workers are divided into pages according to paginator and paginator
// specified page is returned. Additional metadata are returned as a pointer to ListInfo.
ListWorkers(filter ListFilter, sorter *SortInfo, paginator *WorkersPaginator) ([]WorkerInfo,
*ListInfo, error)
// GetWorkerInfo returns WorkerInfo of specified worker.
GetWorkerInfo(uuid WorkerUUID) (WorkerInfo, error)
// SetState sets the Worker's state to either MAINTENANCE or IDLE.
SetState(uuid WorkerUUID, state WorkerState) error
// SetGroups updates the groups parameter of the Worker.
SetGroups(uuid WorkerUUID, groups Groups) error
// Deregister removes the Worker from the system.
// It can only succeed if the Worker is in the MAINTENANCE mode.
Deregister(uuid WorkerUUID) error
}
Workers defines all actions that can be done by users and admins on workers. Users (and admins) can also call methods from Requests interface.
type WorkersPaginator ¶ added in v0.2.0
type WorkersPaginator struct {
// ID sets page border. When direction is set to forward the page will start with first
// workes after the ID and contain up to Limit items. If direction is set backward then
// page contains up to Limit items before ID.
ID WorkerUUID
// Direction in which list should be traversed.
Direction ListDirection
// Limit up to how many elements can be stored on one page.
Limit uint16
}
WorkersPaginator contains information to get specific page of listed workers.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
boruta
command
|
|
|
dryad
command
|
|
|
Package dryad provides: * implementation of Dryad interface * utilities to manage Dryad and its users
|
Package dryad provides: * implementation of Dryad interface * utilities to manage Dryad and its users |
|
conf
Package conf manages Dryad's configuration.
|
Package conf manages Dryad's configuration. |
|
Package filter provides filters used in listing functions.
|
Package filter provides filters used in listing functions. |
|
Package http provides datatypes that are shared between server and client.
|
Package http provides datatypes that are shared between server and client. |
|
client
Package client provides methods for interaction with Boruta REST API server.
|
Package client provides methods for interaction with Boruta REST API server. |
|
server/api
Package api aggregates all availabe Boruta HTTP API versions.
|
Package api aggregates all availabe Boruta HTTP API versions. |
|
server/api/v1
Package v1 provides HTTP API version 1 of Boruta.
|
Package v1 provides HTTP API version 1 of Boruta. |
|
Package matcher provides interface and implementation for taking actions related to assigning requests to workers and reacting to requests time events.
|
Package matcher provides interface and implementation for taking actions related to assigning requests to workers and reacting to requests time events. |
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
Package requests provides structures and functions to handle requests.
|
Package requests provides structures and functions to handle requests. |
|
rpc
|
|
|
superviser
Package superviser provides Go RPC implementation of client and server for Superviser interface.
|
Package superviser provides Go RPC implementation of client and server for Superviser interface. |
|
types
Package types contains gob registration of types needed for RPC communication between dryad and supervisor.
|
Package types contains gob registration of types needed for RPC communication between dryad and supervisor. |
|
Package tunnels allows creation of simple forwarding tunnels between address pairs.
|
Package tunnels allows creation of simple forwarding tunnels between address pairs. |
|
Package workers is responsible for worker list management.
|
Package workers is responsible for worker list management. |