queue

package
v0.0.0-...-d6ee231 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildletPriority

type BuildletPriority int
const (
	// PriorityUrgent is reserved for Go releases.
	PriorityUrgent BuildletPriority = iota
	PriorityInteractive
	PriorityAutomated
	PriorityBatch
)

type Item

type Item struct {
	// contains filtered or unexported fields
}

An Item is something we manage in a priority buildletQueue.

func (*Item) Await

func (i *Item) Await(ctx context.Context) error

Await blocks until the Item holds the necessary quota amount, or the context is cancelled.

On success, the caller must call ReturnQuota() to release the quota.

func (*Item) ReturnQuota

func (i *Item) ReturnQuota()

ReturnQuota returns quota to the Queue. ReturnQuota is a no-op if the item has never been popped.

func (*Item) SchedItem

func (i *Item) SchedItem() *SchedItem

SchedItem returns a copy of the SchedItem for a build.

type ItemStats

type ItemStats struct {
	Build *SchedItem
	Cost  int
}

type Quota

type Quota struct {
	// contains filtered or unexported fields
}

Quota manages a queue for a single quota.

func NewQuota

func NewQuota() *Quota

NewQuota returns an initialized *Quota ready for use.

func (*Quota) AwaitQueue

func (q *Quota) AwaitQueue(ctx context.Context, cost int, si *SchedItem) error

AwaitQueue enqueues a build and returns once the item is unblocked by quota, by order of minimum priority.

If the provided context is cancelled before popping, the item is removed from the queue and an error is returned.

func (*Quota) Empty

func (q *Quota) Empty() bool

Empty returns true when there are no items in the queue.

func (*Quota) Enqueue

func (q *Quota) Enqueue(cost int, si *SchedItem) *Item

Enqueue a build and return an Item. See Item's documentation for waiting and releasing quota.

func (*Quota) Len

func (q *Quota) Len() int

Len returns the number of items in the queue.

func (*Quota) Quotas

func (q *Quota) Quotas() Usage

Quotas returns the used, limit, and untracked values for the queue.

func (*Quota) ReturnQuota

func (q *Quota) ReturnQuota(v int)

ReturnQuota decrements the used quota value by v.

func (*Quota) ToExported

func (q *Quota) ToExported() *QuotaStats

func (*Quota) UpdateLimit

func (q *Quota) UpdateLimit(limit int)

UpdateLimit updates the limit values on the queue.

func (*Quota) UpdateQuotas

func (q *Quota) UpdateQuotas(used, limit int)

UpdateQuotas updates the limit and used values on the queue.

func (*Quota) UpdateUntracked

func (q *Quota) UpdateUntracked(n int)

type QuotaStats

type QuotaStats struct {
	Usage
	Items []ItemStats
}

type SchedItem

type SchedItem struct {
	buildgo.BuilderRev // not set for gomote
	HostType           string
	IsRelease          bool
	IsGomote           bool
	IsTry              bool
	IsHelper           bool
	Repo               string
	Branch             string // the Go repository branch

	// CommitTime is the latest commit date of the relevant repos
	// that make up the work being tested. (For example, x/foo
	// being tested against master can have either x/foo commit
	// being newer, or master being newer).
	CommitTime  time.Time
	RequestTime time.Time
	User        string
}

SchedItem is a specification of a requested buildlet in its exported fields, and internal scheduler state used while waiting for that buildlet.

SchedItem is safe for copying.

func (*SchedItem) Less

func (s *SchedItem) Less(other *SchedItem) bool

Less returns a boolean value of whether SchedItem is more important than the provided SchedItem.

func (*SchedItem) Priority

func (s *SchedItem) Priority() BuildletPriority

Priority returns the BuildletPriority for a SchedItem.

func (*SchedItem) SortTime

func (s *SchedItem) SortTime() time.Time

type Usage

type Usage struct {
	Used          int
	Limit         int
	UntrackedUsed int
}

Jump to

Keyboard shortcuts

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