datalayer

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 8 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBLayer

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

DBLayer is an DataLayer instance that interacts with the Cassandra database

func NewDBLayer

func NewDBLayer(s *gocql.Session, sname string) *DBLayer

NewDBLayer returns a data layer object

func (*DBLayer) CreateBuild

func (dl *DBLayer) CreateBuild(ctx context.Context, req *lib.BuildRequest) (id gocql.UUID, err error)

CreateBuild inserts a new build into the DB returning the ID

func (*DBLayer) DeleteBuild

func (dl *DBLayer) DeleteBuild(ctx context.Context, id gocql.UUID) (err error)

DeleteBuild removes a build from the DB. Only used in case of queue full when we can't actually do a build

func (*DBLayer) GetBuildByID

func (dl *DBLayer) GetBuildByID(ctx context.Context, id gocql.UUID) (bi *lib.BuildStatusResponse, err error)

GetBuildByID fetches a build object from the DB

func (*DBLayer) GetBuildOutput

func (dl *DBLayer) GetBuildOutput(ctx context.Context, id gocql.UUID, column string) (output []lib.BuildEvent, err error)

GetBuildOutput returns an array of stream events from the database

func (*DBLayer) SaveBuildOutput

func (dl *DBLayer) SaveBuildOutput(ctx context.Context, id gocql.UUID, output []lib.BuildEvent, column string) (err error)

SaveBuildOutput serializes an array of stream events to the database

func (*DBLayer) SetBuildCompletedTimestamp

func (dl *DBLayer) SetBuildCompletedTimestamp(ctx context.Context, id gocql.UUID) (err error)

SetBuildCompletedTimestamp sets the completed timestamp on a build to time.Now()

func (*DBLayer) SetBuildFlags

func (dl *DBLayer) SetBuildFlags(ctx context.Context, id gocql.UUID, flags map[string]bool) (err error)

SetBuildFlags sets the boolean flags on the build object Caller must ensure that the flags passed in are valid

func (*DBLayer) SetBuildState

func (dl *DBLayer) SetBuildState(ctx context.Context, id gocql.UUID, state lib.BuildStatusResponse_BuildState) (err error)

SetBuildState sets the state of a build

func (*DBLayer) SetBuildTimeMetric

func (dl *DBLayer) SetBuildTimeMetric(ctx context.Context, id gocql.UUID, metric string) (err error)

SetBuildTimeMetric sets a build metric to time.Now() metric is the name of the column to update if metric is a *_completed column, it will also compute and persist the duration

func (*DBLayer) SetDockerImageSizesMetric

func (dl *DBLayer) SetDockerImageSizesMetric(ctx context.Context, id gocql.UUID, size int64, vsize int64) (err error)

SetDockerImageSizesMetric sets the docker image sizes for a build

type DataLayer

type DataLayer interface {
	CreateBuild(context.Context, *lib.BuildRequest) (gocql.UUID, error)
	GetBuildByID(context.Context, gocql.UUID) (*lib.BuildStatusResponse, error)
	SetBuildFlags(context.Context, gocql.UUID, map[string]bool) error
	SetBuildCompletedTimestamp(context.Context, gocql.UUID) error
	SetBuildState(context.Context, gocql.UUID, lib.BuildStatusResponse_BuildState) error
	DeleteBuild(context.Context, gocql.UUID) error
	SetBuildTimeMetric(context.Context, gocql.UUID, string) error
	SetDockerImageSizesMetric(context.Context, gocql.UUID, int64, int64) error
	SaveBuildOutput(context.Context, gocql.UUID, []lib.BuildEvent, string) error
	GetBuildOutput(context.Context, gocql.UUID, string) ([]lib.BuildEvent, error)
}

DataLayer describes an object that interacts with the persistent data store

Jump to

Keyboard shortcuts

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