db

package
v0.0.0-...-1327151 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package db provides a database storage layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitModule

type CommitModule struct {
	CommitSHA  string
	CommitTime time.Time
	ModuleUUID uuid.UUID
}

CommitModule represents a commit module pair.

type DB

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

DB provides database access.

func New

func New(ctx context.Context, d *sql.DB) (*DB, error)

New builds a database layer backed by the given postgres connection.

func Open

func Open(ctx context.Context, conn string) (*DB, error)

Open postgres database connection with the given connection string.

func (*DB) Close

func (d *DB) Close() error

Close database connection.

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

func (d *DB) FindBenchmarkByUUID(ctx context.Context, id uuid.UUID) (*entity.Benchmark, error)

FindBenchmarkByUUID looks up the given benchmark in the database.

func (*DB) FindCommitBySHA

func (d *DB) FindCommitBySHA(ctx context.Context, sha string) (*entity.Commit, error)

FindCommitBySHA looks up the given commit in the database.

func (*DB) FindDataFileByUUID

func (d *DB) FindDataFileByUUID(ctx context.Context, id uuid.UUID) (*entity.DataFile, error)

FindDataFileByUUID looks up the given data file in the database.

func (*DB) FindModuleByUUID

func (d *DB) FindModuleByUUID(ctx context.Context, id uuid.UUID) (*entity.Module, error)

FindModuleByUUID looks up the given module in the database.

func (*DB) FindPackageByUUID

func (d *DB) FindPackageByUUID(ctx context.Context, id uuid.UUID) (*entity.Package, error)

FindPackageByUUID looks up the given package in the database.

func (*DB) FindPropertiesByUUID

func (d *DB) FindPropertiesByUUID(ctx context.Context, id uuid.UUID) (entity.Properties, error)

FindPropertiesByUUID looks up the given properties in the database.

func (*DB) FindResultByUUID

func (d *DB) FindResultByUUID(ctx context.Context, id uuid.UUID) (*entity.Result, error)

FindResultByUUID looks up a result in the database given the ID.

func (*DB) FindTaskByUUID

func (d *DB) FindTaskByUUID(ctx context.Context, id uuid.UUID) (*entity.Task, error)

FindTaskByUUID looks up the given task in the database.

func (*DB) ListBenchmarkPoints

func (d *DB) ListBenchmarkPoints(ctx context.Context, b *entity.Benchmark, n int) (entity.Points, error)

ListBenchmarkPoints returns n most recent timeseries points for the given benchmark.

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) 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

func (d *DB) ListModulePackages(ctx context.Context, m *entity.Module) ([]*entity.Package, error)

ListModulePackages returns all packages in the given module.

func (*DB) ListModules

func (d *DB) ListModules(ctx context.Context) ([]*entity.Module, error)

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) ListWorkerTasksPending

func (d *DB) ListWorkerTasksPending(ctx context.Context, worker string) ([]*entity.Task, error)

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

func (d *DB) MostRecentCommit(ctx context.Context) (*entity.Commit, error)

MostRecentCommit returns the most recent commit by commit time.

func (*DB) RecordTaskDataUpload

func (d *DB) RecordTaskDataUpload(ctx context.Context, id uuid.UUID, f *entity.DataFile) error

RecordTaskDataUpload inserts the given datafile and associates it with the supplied task ID.

func (*DB) SetLogger

func (d *DB) SetLogger(l *zap.Logger)

SetLogger configures a logger.

func (*DB) StoreBenchmark

func (d *DB) StoreBenchmark(ctx context.Context, b *entity.Benchmark) error

StoreBenchmark writes benchmark to the database.

func (*DB) StoreCommit

func (d *DB) StoreCommit(ctx context.Context, c *entity.Commit) error

StoreCommit writes commit to the database.

func (*DB) StoreCommits

func (d *DB) StoreCommits(ctx context.Context, cs []*entity.Commit) error

StoreCommits writes the given commits to the database.

func (*DB) StoreDataFile

func (d *DB) StoreDataFile(ctx context.Context, f *entity.DataFile) error

StoreDataFile writes the data file to the database.

func (*DB) StoreModule

func (d *DB) StoreModule(ctx context.Context, m *entity.Module) error

StoreModule writes module to the database.

func (*DB) StorePackage

func (d *DB) StorePackage(ctx context.Context, p *entity.Package) error

StorePackage writes package to the database.

func (*DB) StoreProperties

func (d *DB) StoreProperties(ctx context.Context, p entity.Properties) error

StoreProperties writes properties to the database.

func (*DB) StoreResult

func (d *DB) StoreResult(ctx context.Context, r *entity.Result) error

StoreResult writes a result to the database.

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) TruncateNonStatic

func (d *DB) TruncateNonStatic(ctx context.Context) error

TruncateNonStatic deletes almost all data from the database. Only static tables such as commits and modules are preserved.

Directories

Path Synopsis
Package dbtest provides helpers for testing the database storage layer.
Package dbtest provides helpers for testing the database storage layer.
internal
db

Jump to

Keyboard shortcuts

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