Documentation ¶
Overview ¶
Package db provides a database storage layer.
Index ¶
- type ChangeFilter
- type CommitModule
- type CommitModuleError
- type DB
- func (d *DB) BuildChangesRanked(ctx context.Context) error
- func (d *DB) BuildCommitPositions(ctx context.Context) error
- func (d *DB) Close() error
- func (d *DB) CreateTask(ctx context.Context, worker string, s entity.TaskSpec) (*entity.Task, error)
- func (d *DB) FindBenchmarkByUUID(ctx context.Context, id uuid.UUID) (*entity.Benchmark, error)
- func (d *DB) FindCommitBySHA(ctx context.Context, sha string) (*entity.Commit, error)
- func (d *DB) FindCommitIndexBySHA(ctx context.Context, sha string) (int, error)
- func (d *DB) FindDataFileByUUID(ctx context.Context, id uuid.UUID) (*entity.DataFile, error)
- func (d *DB) FindModuleByUUID(ctx context.Context, id uuid.UUID) (*entity.Module, error)
- func (d *DB) FindPackageByUUID(ctx context.Context, id uuid.UUID) (*entity.Package, error)
- func (d *DB) FindPropertiesByUUID(ctx context.Context, id uuid.UUID) (entity.Properties, error)
- func (d *DB) FindResultByUUID(ctx context.Context, id uuid.UUID) (*entity.Result, error)
- func (d *DB) FindTaskByUUID(ctx context.Context, id uuid.UUID) (*entity.Task, error)
- func (d *DB) ListBenchmarkPoints(ctx context.Context, b *entity.Benchmark, r entity.CommitIndexRange) (entity.Points, error)
- func (d *DB) ListBenchmarkResults(ctx context.Context, b *entity.Benchmark) ([]*entity.Result, error)
- func (d *DB) ListChangeSummaries(ctx context.Context, r entity.CommitIndexRange, filter ChangeFilter) ([]*entity.ChangeSummary, error)
- func (d *DB) ListChangeSummariesForCommitIndex(ctx context.Context, idx int, filter ChangeFilter) ([]*entity.ChangeSummary, error)
- func (d *DB) ListCommitModuleErrors(ctx context.Context, worker string, maxErrors int, lastAttempt time.Time, ...) ([]CommitModuleError, error)
- func (d *DB) ListCommitModulesWithoutCompleteTasks(ctx context.Context, worker string, n int) ([]CommitModule, error)
- func (d *DB) ListModulePackages(ctx context.Context, m *entity.Module) ([]*entity.Package, error)
- func (d *DB) ListModules(ctx context.Context) ([]*entity.Module, error)
- func (d *DB) ListPackageBenchmarks(ctx context.Context, p *entity.Package) ([]*entity.Benchmark, error)
- func (d *DB) ListTasksWithStatus(ctx context.Context, statuses []entity.TaskStatus) ([]*entity.Task, error)
- func (d *DB) ListTracePoints(ctx context.Context, r entity.CommitIndexRange) ([]trace.Point, error)
- func (d *DB) ListWorkerTasksPending(ctx context.Context, worker string) ([]*entity.Task, error)
- func (d *DB) ListWorkerTasksWithStatus(ctx context.Context, worker string, statuses []entity.TaskStatus) ([]*entity.Task, error)
- func (d *DB) MostRecentCommit(ctx context.Context) (*entity.Commit, error)
- func (d *DB) MostRecentCommitIndex(ctx context.Context) (int, error)
- func (d *DB) MostRecentCommitWithRef(ctx context.Context, ref string) (*entity.Commit, error)
- func (d *DB) RecordTaskDataUpload(ctx context.Context, id uuid.UUID, f *entity.DataFile) error
- func (d *DB) ReplaceChanges(ctx context.Context, r entity.CommitIndexRange, cs []*entity.Change) error
- func (d *DB) SetLogger(l *zap.Logger)
- func (d *DB) StoreBenchmark(ctx context.Context, b *entity.Benchmark) error
- func (d *DB) StoreChangesBatch(ctx context.Context, cs []*entity.Change) error
- func (d *DB) StoreCommit(ctx context.Context, c *entity.Commit) error
- func (d *DB) StoreCommitPosition(ctx context.Context, p *entity.CommitPosition) error
- func (d *DB) StoreCommitRef(ctx context.Context, r *entity.CommitRef) error
- func (d *DB) StoreCommitRefs(ctx context.Context, rs []*entity.CommitRef) error
- func (d *DB) StoreCommits(ctx context.Context, cs []*entity.Commit) error
- func (d *DB) StoreDataFile(ctx context.Context, f *entity.DataFile) error
- func (d *DB) StoreModule(ctx context.Context, m *entity.Module) error
- func (d *DB) StorePackage(ctx context.Context, p *entity.Package) error
- func (d *DB) StoreProperties(ctx context.Context, p entity.Properties) error
- func (d *DB) StoreResult(ctx context.Context, r *entity.Result) error
- func (d *DB) StoreResults(ctx context.Context, rs []*entity.Result) error
- func (d *DB) TimeoutStaleTasks(ctx context.Context, until time.Time) error
- func (d *DB) Trace(ctx context.Context, id trace.ID, r entity.CommitIndexRange) (*trace.Trace, error)
- func (d *DB) TransitionTaskStatus(ctx context.Context, id uuid.UUID, from []entity.TaskStatus, ...) error
- func (d *DB) TransitionTaskStatusesBefore(ctx context.Context, from []entity.TaskStatus, to entity.TaskStatus, ...) error
- func (d *DB) TruncateAll(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeFilter ¶
type ChangeFilter struct { MinEffectSize float64 MaxRankByEffectSize int MaxRankByAbsPercentChange int }
ChangeFilter specifies thresholds for change listings.
type CommitModule ¶
CommitModule represents a commit module pair.
type CommitModuleError ¶
type CommitModuleError struct { ModuleUUID uuid.UUID CommitSHA string NumErrors int LastAttempt time.Time }
CommitModuleError represents a commit module pair that has no completed tasks and at least one error.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB provides database access.
func (*DB) BuildChangesRanked ¶
BuildChangesRanked derives the ranked changes table from the changes table.
func (*DB) BuildCommitPositions ¶
BuildCommitPositions creates the commit positions table. The table is completely rebuilt from the source tables.
func (*DB) CreateTask ¶
func (d *DB) CreateTask(ctx context.Context, worker string, s entity.TaskSpec) (*entity.Task, error)
CreateTask creates a new task.
func (*DB) FindBenchmarkByUUID ¶
FindBenchmarkByUUID looks up the given benchmark in the database.
func (*DB) FindCommitBySHA ¶
FindCommitBySHA looks up the given commit in the database.
func (*DB) FindCommitIndexBySHA ¶
FindCommitIndexBySHA looks up the commit index for a SHA.
func (*DB) FindDataFileByUUID ¶
FindDataFileByUUID looks up the given data file in the database.
func (*DB) FindModuleByUUID ¶
FindModuleByUUID looks up the given module in the database.
func (*DB) FindPackageByUUID ¶
FindPackageByUUID looks up the given package in the database.
func (*DB) FindPropertiesByUUID ¶
FindPropertiesByUUID looks up the given properties in the database.
func (*DB) FindResultByUUID ¶
FindResultByUUID looks up a result in the database given the ID.
func (*DB) FindTaskByUUID ¶
FindTaskByUUID looks up the given task in the database.
func (*DB) ListBenchmarkPoints ¶
func (d *DB) ListBenchmarkPoints(ctx context.Context, b *entity.Benchmark, r entity.CommitIndexRange) (entity.Points, error)
ListBenchmarkPoints returns timeseries points for the given benchmark and commit index range.
func (*DB) ListBenchmarkResults ¶
func (d *DB) ListBenchmarkResults(ctx context.Context, b *entity.Benchmark) ([]*entity.Result, error)
ListBenchmarkResults returns all results for the given benchmark.
func (*DB) ListChangeSummaries ¶
func (d *DB) ListChangeSummaries(ctx context.Context, r entity.CommitIndexRange, filter ChangeFilter) ([]*entity.ChangeSummary, error)
ListChangeSummaries returns changes with associated metadata.
func (*DB) ListChangeSummariesForCommitIndex ¶
func (d *DB) ListChangeSummariesForCommitIndex(ctx context.Context, idx int, filter ChangeFilter) ([]*entity.ChangeSummary, error)
ListChangeSummariesForCommitIndex returns changes at a specific commit.
func (*DB) ListCommitModuleErrors ¶
func (d *DB) ListCommitModuleErrors(ctx context.Context, worker string, maxErrors int, lastAttempt time.Time, n int) ([]CommitModuleError, error)
ListCommitModuleErrors returns up to n commit module pairs that have errored on the given worker with no successful execution. The search is limited to pairs with at most maxErrors errors and last attempt before the given timestamp. This is intended for identifying tasks that should be retried.
func (*DB) ListCommitModulesWithoutCompleteTasks ¶
func (d *DB) ListCommitModulesWithoutCompleteTasks(ctx context.Context, worker string, n int) ([]CommitModule, error)
ListCommitModulesWithoutCompleteTasks searches for n recent commit module pairs without completed tasks for the given worker.
func (*DB) ListModulePackages ¶
ListModulePackages returns all packages in the given module.
func (*DB) ListModules ¶
ListModules returns all modules.
func (*DB) ListPackageBenchmarks ¶
func (d *DB) ListPackageBenchmarks(ctx context.Context, p *entity.Package) ([]*entity.Benchmark, error)
ListPackageBenchmarks returns all benchmarks in the given package.
func (*DB) ListTasksWithStatus ¶
func (d *DB) ListTasksWithStatus(ctx context.Context, statuses []entity.TaskStatus) ([]*entity.Task, error)
ListTasksWithStatus returns tasks in the given states.
func (*DB) ListTracePoints ¶
ListTracePoints returns trace points for the given commit range.
func (*DB) ListWorkerTasksPending ¶
ListWorkerTasksPending returns tasks assigned to a worker in a pending state.
func (*DB) ListWorkerTasksWithStatus ¶
func (d *DB) ListWorkerTasksWithStatus(ctx context.Context, worker string, statuses []entity.TaskStatus) ([]*entity.Task, error)
ListWorkerTasksWithStatus returns tasks assigned to a worker in the given states.
func (*DB) MostRecentCommit ¶
MostRecentCommit returns the most recent commit by commit time.
func (*DB) MostRecentCommitIndex ¶
MostRecentCommitIndex returns the most recent commit index.
func (*DB) MostRecentCommitWithRef ¶
MostRecentCommitWithRef returns the most recent commit by commit time having the supplied ref.
func (*DB) RecordTaskDataUpload ¶
RecordTaskDataUpload inserts the given datafile and associates it with the supplied task ID.
func (*DB) ReplaceChanges ¶
func (d *DB) ReplaceChanges(ctx context.Context, r entity.CommitIndexRange, cs []*entity.Change) error
ReplaceChanges transactionally deletes changes in a range and inserts supplied changes.
func (*DB) StoreBenchmark ¶
StoreBenchmark writes benchmark to the database.
func (*DB) StoreChangesBatch ¶
StoreChangesBatch writes the given changes to the database in a single batch. Does not write any dependent objects.
func (*DB) StoreCommit ¶
StoreCommit writes commit to the database.
func (*DB) StoreCommitPosition ¶
StoreCommitPosition writes a commit position to the database. This should be rarely needed outside of testing; prefer BuildCommitPositions.
func (*DB) StoreCommitRef ¶
StoreCommitRef writes a commit ref pair to the database.
func (*DB) StoreCommitRefs ¶
StoreCommitRefs writes the given commit refs to the database.
func (*DB) StoreCommits ¶
StoreCommits writes the given commits to the database in a single batch.
func (*DB) StoreDataFile ¶
StoreDataFile writes the data file to the database.
func (*DB) StoreModule ¶
StoreModule writes module to the database.
func (*DB) StorePackage ¶
StorePackage writes package to the database.
func (*DB) StoreProperties ¶
StoreProperties writes properties to the database.
func (*DB) StoreResult ¶
StoreResult writes a result to the database.
func (*DB) StoreResults ¶
StoreResults writes results to the database.
func (*DB) TimeoutStaleTasks ¶
TimeoutStaleTasks marks stale all pending tasks with last update before until.
func (*DB) Trace ¶
func (d *DB) Trace(ctx context.Context, id trace.ID, r entity.CommitIndexRange) (*trace.Trace, error)
Trace returns a specific trace between the given commit range.
func (*DB) TransitionTaskStatus ¶
func (d *DB) TransitionTaskStatus(ctx context.Context, id uuid.UUID, from []entity.TaskStatus, to entity.TaskStatus) error
TransitionTaskStatus performs the given task status transition.
func (*DB) TransitionTaskStatusesBefore ¶
func (d *DB) TransitionTaskStatusesBefore(ctx context.Context, from []entity.TaskStatus, to entity.TaskStatus, until time.Time) error
TransitionTaskStatusesBefore applies a task status transition to all tasks that were last updated before the until timestamp.