task_common

package
v0.0.0-...-03d6fc4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default page size used for pagination.
	DEFAULT_PAGE_SIZE = 10

	// Maximum page size used for pagination.
	MAX_PAGE_SIZE = 100
)

Variables

This section is empty.

Functions

func AddHandlers

func AddHandlers(externalRouter, internalRouter *mux.Router)

func AddTask

func AddTask(ctx context.Context, task AddTaskVars) (int64, error)

Returns the ID of the inserted task if the operation was successful.

func AddTaskHandler

func AddTaskHandler(w http.ResponseWriter, r *http.Request, task AddTaskVars)

func DatastoreTaskQuery

func DatastoreTaskQuery(ctx context.Context, prototype Task, params QueryParams) *datastore.Iterator

func DeleteTaskHandler

func DeleteTaskHandler(prototype Task, w http.ResponseWriter, r *http.Request)

func GetNextId

func GetNextId(ctx context.Context, kind ds.Kind, task Task) (int64, error)

func GetTasksHandler

func GetTasksHandler(prototype Task, w http.ResponseWriter, r *http.Request)

func HasPageSetsColumn

func HasPageSetsColumn(prototype Task) bool

func RedoTaskHandler

func RedoTaskHandler(prototype Task, w http.ResponseWriter, r *http.Request)

func UpdateTask

func UpdateTask(ctx context.Context, vars UpdateTaskVars, task Task) error

func UpdateTaskHandler

func UpdateTaskHandler(vars UpdateTaskVars, prototype Task, w http.ResponseWriter, r *http.Request)

Types

type AddTaskCommonVars

type AddTaskCommonVars struct {
	Username        string
	TsAdded         string
	RepeatAfterDays string `json:"repeat_after_days"`
}

Data included in all tasks; set by AddTaskHandler.

func (*AddTaskCommonVars) GetAddTaskCommonVars

func (vars *AddTaskCommonVars) GetAddTaskCommonVars() *AddTaskCommonVars

func (*AddTaskCommonVars) IsAdminTask

func (vars *AddTaskCommonVars) IsAdminTask() bool

type AddTaskVars

type AddTaskVars interface {
	GetAddTaskCommonVars() *AddTaskCommonVars
	IsAdminTask() bool
	GetDatastoreKind() ds.Kind
	GetPopulatedDatastoreTask(ctx context.Context) (Task, error)
}

type ByPageSetDesc

type ByPageSetDesc []PageSet

ByPageSetDesc implements sort.Interface to order PageSets by their descriptions.

func (ByPageSetDesc) Len

func (p ByPageSetDesc) Len() int

func (ByPageSetDesc) Less

func (p ByPageSetDesc) Less(i, j int) bool

func (ByPageSetDesc) Swap

func (p ByPageSetDesc) Swap(i, j int)

type ClusterTelemetryIDs

type ClusterTelemetryIDs struct {
	HighestID int64
}

type CommonCols

type CommonCols struct {
	DatastoreKey    *datastore.Key `datastore:"__key__"`
	TsAdded         int64
	TsStarted       int64
	TsCompleted     int64
	Username        string
	Failure         bool
	RepeatAfterDays int64
	SwarmingLogs    string
	TaskDone        bool
}

func (*CommonCols) GetCommonCols

func (dbrow *CommonCols) GetCommonCols() *CommonCols

type PageSet

type PageSet struct {
	Key         string `json:"key"`
	Description string `json:"description"`
}

type QueryParams

type QueryParams struct {
	// If non-empty, limits to only tasks with the given username.
	Username string
	// Include only tasks that have completed successfully.
	SuccessfulOnly bool
	// Include only tasks that are not yet completed.
	PendingOnly bool
	// Include only completed tasks that are scheduled to repeat.
	FutureRunsOnly bool
	// Exclude tasks where page_sets is PAGESET_TYPE_DUMMY_1k.
	ExcludeDummyPageSets bool
	// If true, SELECT COUNT(*). If false, SELECT * and include ORDER BY and LIMIT clauses.
	CountQuery bool
	// First term of LIMIT clause; ignored if countQuery is true.
	Offset int
	// Second term of LIMIT clause; ignored if countQuery is true.
	Size int
}

type Task

type Task interface {
	GetCommonCols() *CommonCols
	GetTaskName() string
	GetDatastoreKind() ds.Kind
	// Returns a slice of the struct type.
	Query(it *datastore.Iterator) (interface{}, error)
	// Returns the struct type.
	Get(c context.Context, key *datastore.Key) (Task, error)
	// Returns the corresponding UpdateTaskVars instance of this Task. The
	// returned instance is not populated.
	GetUpdateTaskVars() UpdateTaskVars
	// Returns the corresponding AddTaskVars instance of this Task. The returned
	// instance is populated.
	GetPopulatedAddTaskVars() (AddTaskVars, error)
	// Returns the results link for this task if it completed successfully and if
	// the task supports results links.
	GetResultsLink() string
}

func AsTaskSlice

func AsTaskSlice(selectResult interface{}) []Task

Takes the result of Task.Query and returns a slice of Tasks containing the same objects.

type UpdateTaskCommonVars

type UpdateTaskCommonVars struct {
	Id                   int64
	TsStarted            string
	TsCompleted          string
	Failure              bool
	TaskDone             bool
	RepeatAfterDays      int64
	ClearRepeatAfterDays bool
	SwarmingLogs         string
}

Data included in all update requests.

func (*UpdateTaskCommonVars) GetUpdateTaskCommonVars

func (vars *UpdateTaskCommonVars) GetUpdateTaskCommonVars() *UpdateTaskCommonVars

func (*UpdateTaskCommonVars) SetCompleted

func (vars *UpdateTaskCommonVars) SetCompleted(success bool)

func (*UpdateTaskCommonVars) SetStarted

func (vars *UpdateTaskCommonVars) SetStarted(runID string)

type UpdateTaskVars

type UpdateTaskVars interface {
	GetUpdateTaskCommonVars() *UpdateTaskCommonVars
	UriPath() string
	// Adds CT task specific updates for fields not in UpdateTaskCommonVars.
	UpdateExtraFields(Task) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL