incremental

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: 15 Imported by: 0

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 struct {
	// contains filtered or unexported fields
}

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.

func NewIncrementalCache

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

NewIncrementalCache returns an IncrementalCache instance.

func (*IncrementalCache) Get

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

Get returns all newly-obtained data since the given time, trimmed to maxComits.

func (*IncrementalCache) GetAll

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

GetAll returns all of the data in the cache, trimmed to maxCommits.

func (*IncrementalCache) GetRange

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

GetRange returns all newly-obtained data in the given time range, trimmed to maxCommits.

func (*IncrementalCache) Update

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

Update obtains new data and stores it internally keyed by the current time.

func (*IncrementalCache) UpdateLoop

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

UpdateLoop runs c.Update() in a loop. Automatically resets the cache every 24 hours.

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      []*gitinfo.GitBranch                 `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 IncrementalCache, 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