incremental

package
v0.0.0-...-0390e60 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitComment

type CommitComment struct {
	types.CommitComment
	Id string `json:"id"`
}

CommitComment is a wrapper around types.CommitComment which interprets the timestamp (in nanoseconds) as the ID, for convenience.

type IncrementalCache

type IncrementalCache interface {
	// Get returns all newly-obtained data since the given time, trimmed to
	// maxCommits.
	Get(repo string, since time.Time, maxCommits int) (*Update, error)

	// GetAll returns all of the data in the cache, trimmed to maxCommits.
	GetAll(repo string, maxCommits int) (*Update, error)

	// GetRange returns all newly-obtained data in the given time range,
	// trimmed to maxCommits.
	GetRange(repo string, from, to time.Time, maxCommits int) (*Update, error)

	// Update obtains new data and stores it internally keyed by the current
	// time.
	Update(ctx context.Context, reset bool) error

	// UpdateLoop runs c.Update() in a loop. Automatically resets the cache
	// every 24 hours.
	UpdateLoop(ctx context.Context, frequency time.Duration)
}

IncrementalCache is a cache used for sending only new information to a client. New data is obtained at each Update() tick and stored internally with a timestamp. When the client requests new data, we return a combined set of Updates.

type IncrementalCacheImpl

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

func NewIncrementalCacheImpl

func NewIncrementalCacheImpl(ctx context.Context, d db.RemoteDB, w window.Window, repos repograph.Map, numCommits int, swarmingUrl, taskSchedulerUrl string) (*IncrementalCacheImpl, error)

NewIncrementalCacheImpl returns an IncrementalCacheImpl instance.

func (*IncrementalCacheImpl) Get

func (c *IncrementalCacheImpl) Get(repo string, since time.Time, maxCommits int) (*Update, error)

Get implements IncrementalCache.

func (*IncrementalCacheImpl) GetAll

func (c *IncrementalCacheImpl) GetAll(repo string, maxCommits int) (*Update, error)

GetAll implements IncrementalCache.

func (*IncrementalCacheImpl) GetRange

func (c *IncrementalCacheImpl) GetRange(repo string, from, to time.Time, maxCommits int) (*Update, error)

GetRange implements IncrementalCache.

func (*IncrementalCacheImpl) Update

func (c *IncrementalCacheImpl) Update(ctx context.Context, reset bool) error

Update implements IncrementalCache.

func (*IncrementalCacheImpl) UpdateLoop

func (c *IncrementalCacheImpl) UpdateLoop(ctx context.Context, frequency time.Duration)

UpdateLoop implements IncrementalCache.

type RepoComments

type RepoComments struct {
	// CommitComments maps commit hash to the comments for that commit,
	// sorted by timestamp.
	CommitComments map[string][]*CommitComment
	// TaskComments maps commit hash and TaskSpec name to the comments for
	// the matching Task, sorted by timestamp.
	TaskComments map[string]map[string][]*TaskComment
	// TaskSpecComments maps TaskSpec name to the comments for that
	// TaskSpec, sorted by timestamp.
	TaskSpecComments map[string][]*TaskSpecComment
}

RepoComments is a variant of types.RepoComments which uses the above wrappers around the typical comment types.

type Task

type Task struct {
	Commits        []string         `json:"commits"`
	Name           string           `json:"name"`
	Id             string           `json:"id"`
	Revision       string           `json:"revision"`
	Status         types.TaskStatus `json:"status"`
	SwarmingTaskId string           `json:"swarming_task_id"`
}

Task is a trimmed-down version of types.Task for minimizing the amount of data we send to the client.

type TaskComment

type TaskComment struct {
	types.TaskComment
	Id string `json:"id"`
}

TaskComment is a wrapper around types.TaskComment which interprets the timestamp (in nanoseconds) as the ID, for convenience.

type TaskSpecComment

type TaskSpecComment struct {
	types.TaskSpecComment
	Id string `json:"id"`
}

TaskSpecComment is a wrapper around types.TaskSpecComment which interprets the timestamp (in nanoseconds) as the ID, for convenience.

type Update

type Update struct {
	BranchHeads      []*git.Branch                        `json:"branch_heads,omitempty"`
	CommitComments   map[string][]*CommitComment          `json:"commit_comments,omitempty"`
	Commits          []*vcsinfo.LongCommit                `json:"commits,omitempty"`
	StartOver        *bool                                `json:"start_over,omitempty"`
	SwarmingUrl      string                               `json:"swarming_url,omitempty"`
	TaskComments     map[string]map[string][]*TaskComment `json:"task_comments,omitempty"`
	Tasks            []*Task                              `json:"tasks,omitempty"`
	TaskSchedulerUrl string                               `json:"task_scheduler_url,omitempty"`
	TaskSpecComments map[string][]*TaskSpecComment        `json:"task_spec_comments,omitempty"`
	Timestamp        time.Time                            `json:"-"`
}

Update represents all of the new information we obtained in a single Update() tick. Every time Update() is called on IncrementalCacheImpl, a new Update object is stored internally. When the client calls any variant of Get, any new Updates are found and merged into a single Update object to return.

Jump to

Keyboard shortcuts

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