Documentation ¶
Index ¶
- Constants
- func FromTaskID(t TaskID) int64
- type Bot
- type BotEvent
- type BuildToken
- type CIPDPackage
- type Cache
- type Containment
- type ContainmentType
- type DB
- type Digest
- type Filter
- type ResultDB
- type Tables
- type TaskID
- type TaskOutput
- type TaskOutputs
- type TaskProperties
- type TaskRequest
- type TaskResult
- type TaskSlice
- type TaskSort
- type TaskState
- type TaskStateQuery
Constants ¶
const DeadAfter = 10 * time.Minute
DeadAfter is the amount of time after which a bot is considered dead.
Variables ¶
This section is empty.
Functions ¶
func FromTaskID ¶
FromTaskID converts an external key to the internal DB format.
Types ¶
type Bot ¶
type Bot struct { Key string `json:"a,omitempty"` SchemaVersion int `json:"b,omitempty"` Created time.Time `json:"c,omitempty"` LastSeen time.Time `json:"d,omitempty"` Version string `json:"e,omitempty"` Deleted bool `json:"f,omitempty"` Dead bool `json:"g,omitempty"` QuarantinedMsg string `json:"h,omitempty"` MaintenanceMsg string `json:"i,omitempty"` TaskID int64 `json:"j,omitempty"` AuthenticatedAs string `json:"k,omitempty"` Dimensions map[string][]string `json:"l,omitempty"` State []byte `json:"m,omitempty"` ExternalIP string `json:"n,omitempty"` }
Bot represents a bot as known by the server.
type BotEvent ¶
type BotEvent struct { Key int64 `json:"a,omitempty"` SchemaVersion int `json:"b,omitempty"` BotID string `json:"c,omitempty"` // Information about the event. Time time.Time `json:"d,omitempty"` Event string `json:"e,omitempty"` Message string `json:"f,omitempty"` // Information copied for the bot. Version string `json:"g,omitempty"` AuthenticatedAs string `json:"h,omitempty"` Dimensions map[string][]string `json:"i,omitempty"` State []byte `json:"j,omitempty"` ExternalIP string `json:"k,omitempty"` TaskID int64 `json:"l,omitempty"` QuarantinedMsg string `json:"m,omitempty"` MaintenanceMsg string `json:"n,omitempty"` }
BotEvent is an event on a bot.
type BuildToken ¶
type BuildToken struct { BuildID int64 `json:"a,omitempty"` Token string `json:"b,omitempty"` BuildbucketHost string `json:"c,omitempty"` }
BuildToken is a LUCI Buildbucket token.
type CIPDPackage ¶
type CIPDPackage struct { PkgName string `json:"a,omitempty"` Version string `json:"b,omitempty"` Path string `json:"c,omitempty"` }
CIPDPackage declares a LUCI CIPD package.
type Containment ¶
type Containment struct {
ContainmentType ContainmentType `json:"a,omitempty"`
}
Containment declares the type of process containment the bot shall do.
type ContainmentType ¶
type ContainmentType int
ContainmentType declares the type of process containment the bot shall do.
const ( ContainmentNotSpecified ContainmentType = iota ContainmentNone ContainmentAuto ContainmentJobObject )
Valid ContainmentType.
type DB ¶
type DB interface { Tables io.Closer // Snapshot ensures there's a copy on disk in case of a crash. Snapshot() error }
DB is a database backend.
func NewDBSqlite3 ¶
NewDBSqlite3 creates or opens a sqlite3 DB.
type Digest ¶
Digest is a more memory efficient version of rbe.Digest.
type Tables ¶
type Tables interface { TaskRequestGet(id int64, r *TaskRequest) // TaskRequestAdd adds a new TaskRequest. It is immutable so it is an error // to add two TaskRequest with the same key. TaskRequestAdd(r *TaskRequest) TaskRequestCount() int64 TaskRequestSlice(f Filter) ([]TaskRequest, string) TaskResultGet(id int64, r *TaskResult) TaskResultSet(r *TaskResult) TaskResultCount() int64 TaskResultSlice(botid string, f Filter, state TaskStateQuery, sort TaskSort) ([]TaskResult, string) BotGet(id string, b *Bot) BotSet(b *Bot) BotCount(dims map[string]string) (total, quarantined, maintenance, dead, busy int64) BotGetSlice(cursor string, limit int) ([]Bot, string) BotEventAdd(e *BotEvent) BotEventGetSlice(botid string, f Filter) ([]BotEvent, string) }
Tables is the functions to access Swarming DB tables.
type TaskOutput ¶
type TaskOutput struct {
Size int64 `json:"a,omitempty"`
}
TaskOutput stores the task's output.
type TaskOutputs ¶
type TaskOutputs struct {
// contains filtered or unexported fields
}
TaskOutputs is a good enough task outputs manager.
It uses a files backed store.
TODO: Implement compression.
func NewTaskOutputs ¶
func NewTaskOutputs(root string) (*TaskOutputs, error)
NewTaskOutputs returns an initialized TaskOutputs.
func (*TaskOutputs) ReadOutput ¶
func (t *TaskOutputs) ReadOutput(key, offset int64, max int) ([]byte, error)
ReadOutput reads the task output from a file at the specified offset.
type TaskProperties ¶
type TaskProperties struct { Caches []Cache `json:"a,omitempty"` Command []string `json:"b,omitempty"` RelativeWD string `json:"c,omitempty"` CASHost string `json:"d,omitempty"` Input Digest `json:"e,omitempty"` CIPDHost string `json:"f,omitempty"` CIPDClient CIPDPackage `json:"g,omitempty"` CIPDPackages []CIPDPackage `json:"h,omitempty"` Dimensions map[string]string `json:"i,omitempty"` Env map[string]string `json:"j,omitempty"` EnvPrefixes map[string][]string `json:"k,omitempty"` HardTimeout time.Duration `json:"l,omitempty"` GracePeriod time.Duration `json:"m,omitempty"` IOTimeout time.Duration `json:"n,omitempty"` SecretBytes []byte `json:"o,omitempty"` Idempotent bool `json:"p,omitempty"` Outputs []string `json:"q,omitempty"` Containment Containment `json:"r,omitempty"` }
TaskProperties declares what the task runs.
func (*TaskProperties) ValidateAndSetDefaults ¶
func (t *TaskProperties) ValidateAndSetDefaults() error
ValidateAndSetDefaults set default values and returns an error if the task request is invalid.
type TaskRequest ¶
type TaskRequest struct { Key int64 `json:"a,omitempty"` SchemaVersion int64 `json:"b,omitempty"` Created time.Time `json:"c,omitempty"` Priority int32 `json:"d,omitempty"` ParentTask int64 `json:"e,omitempty"` Tags []string `json:"f,omitempty"` TaskSlices []TaskSlice `json:"g,omitempty"` Name string `json:"h,omitempty"` ManualTags []string `json:"i,omitempty"` Authenticated string `json:"j,omitempty"` User string `json:"k,omitempty"` ServiceAccount string `json:"l,omitempty"` PubSubTopic string `json:"m,omitempty"` PubSubAuthToken string `json:"n,omitempty"` PubSubUserData string `json:"o,omitempty"` ResultDBUpdateToken string `json:"p,omitempty"` Realm string `json:"q,omitempty"` ResultDB bool `json:"r,omitempty"` BuildToken BuildToken `json:"s,omitempty"` }
TaskRequest is a single requested task by a client. It is immutable.
func (*TaskRequest) ValidateAndSetDefaults ¶
func (t *TaskRequest) ValidateAndSetDefaults() error
ValidateAndSetDefaults set default values and returns an error if the task request is invalid.
type TaskResult ¶
type TaskResult struct { Key int64 `json:"a,omitempty"` SchemaVersion int `json:"b,omitempty"` BotID string `json:"c,omitempty"` BotVersion string `json:"d,omitempty"` BotDimensions map[string][]string `json:"e,omitempty"` BotIdleSince time.Duration `json:"f,omitempty"` ServerVersions []string `json:"g,omitempty"` CurrentTaskSlice int32 `json:"h,omitempty"` DedupedFrom int64 `json:"i,omitempty"` PropertiesHash string `json:"j,omitempty"` TaskOutput TaskOutput `json:"k,omitempty"` ExitCode int32 `json:"l,omitempty"` InternalFailure string `json:"m,omitempty"` State TaskState `json:"n,omitempty"` Children []int64 `json:"o,omitempty"` Output Digest `json:"p,omitempty"` CIPDClientUsed CIPDPackage `json:"q,omitempty"` CIPDPins []CIPDPackage `json:"r,omitempty"` ResultDB ResultDB `json:"s,omitempty"` Duration time.Duration `json:"t,omitempty"` Started time.Time `json:"u,omitempty"` Completed time.Time `json:"v,omitempty"` Abandoned time.Time `json:"w,omitempty"` Modified time.Time `json:"x,omitempty"` Cost float64 `json:"y,omitempty"` Killing bool `json:"z,omitempty"` DeadAfter time.Time `json:"aa,omitempty"` }
TaskResult is the result of running a TaskRequest.
type TaskSlice ¶
type TaskSlice struct { Properties TaskProperties `json:"a,omitempty"` Expiration time.Duration `json:"b,omitempty"` WaitForCapacity bool `json:"c,omitempty"` }
TaskSlice defines one "option" to run the task.
func (*TaskSlice) ValidateAndSetDefaults ¶
ValidateAndSetDefaults set default values and returns an error if the task request is invalid.
type TaskStateQuery ¶
type TaskStateQuery int
TaskStateQuery filters on different kinds of tasks.
const ( TaskStateQueryPending TaskStateQuery = iota TaskStateQueryRunning TaskStateQueryPendingRunning TaskStateQueryCompleted TaskStateQueryCompletedSuccess TaskStateQueryCompletedFailure TaskStateQueryExpired TaskStateQueryTimedOut TaskStateQueryBotDied TaskStateQueryCanceled TaskStateQueryAll TaskStateQueryDeduped TaskStateQueryKilled TaskStateQueryNoResource )
Valid TaskStateQuery.