model

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskStatus_name = map[int32]string{
		0: "Scheduled",
		1: "Running",
		2: "Succeeded",
		3: "Failed",
		4: "Cancelled",
		5: "Aborted",
	}
	TaskStatus_value = map[string]int32{
		"Scheduled": 0,
		"Running":   1,
		"Succeeded": 2,
		"Failed":    3,
		"Cancelled": 4,
		"Aborted":   5,
	}
)

Enum value maps for TaskStatus.

View Source
var File_infra_appengine_arquebus_app_backend_model_model_proto protoreflect.FileDescriptor

Functions

func GenAssignerKey

func GenAssignerKey(c context.Context, assigner *Assigner) *datastore.Key

GenAssignerKey generates a datastore key for a given assigner object.

func GetTask

func GetTask(c context.Context, assignerID string, taskID int64) (*Assigner, *Task, error)

GetTask returns the Task entity matching with the Assigner and Task IDs.

func UpdateAssigners

func UpdateAssigners(c context.Context, cfgs []*config.Assigner, rev string) error

UpdateAssigners update all the Assigner entities, on presumed valid configs.

For removed configs, the Assigner entities are removed. For new configs, new Assigner entities are created. For updated configs, the Assigner entities are updated, based on the updated content.

Types

type Assigner

type Assigner struct {

	// ID is a globally unique identifier of the assigner.
	ID string `gae:"$id,"`

	// FormatVersion is used to trigger updates even if the config revision
	// stays the same.
	FormatVersion int64 `gae:",noindex"`

	// Owners contain an email list of the owners.
	Owners []string `gae:",noindex"`

	// IssueQueryRaw is a blob with serialized config.IssueQuery.
	//
	// It defines a search query to be sent to Monorail for issue searches.
	IssueQueryRaw []byte `gae:",noindex"`

	// Interval specifies the delay between each individual runs of the
	// assigner.
	Interval time.Duration `gae:",noindex"`

	// AssigneesRaw is a blob with serialized config.UserSource.
	AssigneesRaw [][]byte `gae:",noindex" json:"-"`

	// CCsRaw is a blob with serialized config.UserSource.
	CCsRaw [][]byte `gae:",noindex" json:"-"`

	Description string `gae:",noindex"`
	Comment     string `gae:",noindex"`

	// IsDryRun specifies if the assigner should process tasks without
	// issue update operations.
	IsDryRun bool

	// IsDrained specifies if the assigner has been drained.
	//
	// If an assigner is drained, no tasks are scheduled and run for
	// the assigner.
	IsDrained bool

	// LatestSchedule is the latest timestamp that the Assigner has been
	// scheduled for.
	LatestSchedule time.Time `gae:",noindex"`

	// ConfigRevision specifies the revision of a luci config with which
	// a given assigner entity was last updated.
	//
	// If an Assigner config is removed, this is the revision of the first
	// config push without the removed Assigner config.
	ConfigRevision string `gae:",noindex"`
	// contains filtered or unexported fields
}

Assigner is a job object that periodically runs to perform issue update operations.

func GetAllAssigners

func GetAllAssigners(c context.Context) ([]*Assigner, error)

GetAllAssigners returns all the assigner entities.

func GetAssigner

func GetAssigner(c context.Context, assignerID string) (*Assigner, error)

GetAssigner returns the Assigner entity matching with a given id.

func (*Assigner) Assignees

func (a *Assigner) Assignees() ([]*config.UserSource, error)

Assignees returns a list of UserSource to look for issue assignees from.

func (*Assigner) CCs

func (a *Assigner) CCs() ([]*config.UserSource, error)

CCs returns a list of UserSource to look for whom to cc issues from.

func (*Assigner) HasMostRecentFormat

func (a *Assigner) HasMostRecentFormat() bool

HasMostRecentFormat is false if the entity format is stale.

Stale Assigner entities must be skipped. They'll eventually be updated to have the most recent format.

func (*Assigner) IssueQuery

func (a *Assigner) IssueQuery() (*config.IssueQuery, error)

IssueQuery returns a search query to be sent to Monorail for issue searches.

type Task

type Task struct {
	ID          int64          `gae:"$id"`
	AssignerKey *datastore.Key `gae:"$parent"`

	// ExpectedStart is the time that the task has been scheduled to run for.
	ExpectedStart time.Time
	// Started is the time the task started.
	//
	// The value has no meaning if the task has not run yet.
	Started time.Time `gae:",noindex"`
	// Ended is the time the current task was completed.
	//
	// The value has no meaning until the task has been succeeded or failed.
	Ended time.Time `gae:",noindex"`

	Status TaskStatus
	// WasNoopSuccess is true if the task successfully completed without
	// any issues updated. False, otherwise.
	WasNoopSuccess bool

	// Logs are an optional list of log entries, each is printed in a separate
	// line in UI.
	Logs []logEntry `gae:",noindex"`
	// contains filtered or unexported fields
}

Task keeps track of a single Assigner invocation before, during, and after its execution.

func EnsureScheduledTasks

func EnsureScheduledTasks(c context.Context, assignerID string) ([]*Task, error)

EnsureScheduledTasks ensures that the Assigner has at least one Scheduled Task for upcoming runs.

This function must be invoked within a transaction.

func GetNoopTasks

func GetNoopTasks(c context.Context, assigner *Assigner, limit int32) ([]*Task, error)

GetNoopTasks returns up to |limit| of noop Task entities.

TODO(crbug//967525): remove this function.

func GetTasks

func GetTasks(c context.Context, assigner *Assigner, limit int32, includeNoopSuccess bool) ([]*Task, error)

GetTasks returns up to |limit| of Task entities in ExpectedStart desc order.

If includeNoopSuccess is true, the return includes the Task entities that were completed successfully without issue updates.

TODO(crbug/967522): add pagination

func (*Task) WriteLog

func (task *Task) WriteLog(c context.Context, format string, args ...interface{})

WriteLog appends a new line with the message into the Task entity.

type TaskStatus

type TaskStatus int32

TaskStatus represents the status of an Assigner task.

const (
	// TaskStatusScheduled means that the task has been scheduled, but
	// has not yet started.
	TaskStatus_Scheduled TaskStatus = 0
	// Running means that the task is running.
	TaskStatus_Running TaskStatus = 1
	// Succeeded means that the task completed successfully.
	TaskStatus_Succeeded TaskStatus = 2
	// Failed means that the task failed.
	TaskStatus_Failed TaskStatus = 3
	// Cancelled means that the task was cancelled before starting.
	TaskStatus_Cancelled TaskStatus = 4
	// Aborted means that the task started, but was aborted manually or
	// due to hard deadline.
	TaskStatus_Aborted TaskStatus = 5
)

func (TaskStatus) Descriptor

func (TaskStatus) Descriptor() protoreflect.EnumDescriptor

func (TaskStatus) Enum

func (x TaskStatus) Enum() *TaskStatus

func (TaskStatus) EnumDescriptor deprecated

func (TaskStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use TaskStatus.Descriptor instead.

func (TaskStatus) Number

func (x TaskStatus) Number() protoreflect.EnumNumber

func (TaskStatus) String

func (x TaskStatus) String() string

func (TaskStatus) Type

Jump to

Keyboard shortcuts

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