db

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package db handles our database layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

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

BoltDB is a database using BoltDB

func New

func New(dataDir string) (*BoltDB, error)

New returns a valid locker. We need to be able to write to dataDir since bolt stores its data as a file

func NewWithDB

func NewWithDB(db *bolt.DB, bucket string) (*BoltDB, error)

NewWithDB is used for testing.

func (*BoltDB) DeleteProjectStatus

func (b *BoltDB) DeleteProjectStatus(pull models.PullRequest, workspace string, repoRelDir string) error

DeleteProjectStatus deletes all project statuses under pull that match workspace and repoRelDir.

func (*BoltDB) DeletePullStatus

func (b *BoltDB) DeletePullStatus(pull models.PullRequest) error

DeletePullStatus deletes the status for pull.

func (*BoltDB) GetLock

func (b *BoltDB) GetLock(p models.Project, workspace string) (*models.ProjectLock, error)

GetLock returns a pointer to the lock for that project and workspace. If there is no lock, it returns a nil pointer.

func (*BoltDB) GetPullStatus

func (b *BoltDB) GetPullStatus(pull models.PullRequest) (*models.PullStatus, error)

GetPullStatus returns the status for pull. If there is no status, returns a nil pointer.

func (*BoltDB) List

func (b *BoltDB) List() ([]models.ProjectLock, error)

List lists all current locks.

func (*BoltDB) TryLock

func (b *BoltDB) TryLock(newLock models.ProjectLock) (bool, models.ProjectLock, error)

TryLock attempts to create a new lock. If the lock is acquired, it will return true and the lock returned will be newLock. If the lock is not acquired, it will return false and the current lock that is preventing this lock from being acquired.

func (*BoltDB) Unlock

func (b *BoltDB) Unlock(p models.Project, workspace string) (*models.ProjectLock, error)

Unlock attempts to unlock the project and workspace. If there is no lock, then it will return a nil pointer. If there is a lock, then it will delete it, and then return a pointer to the deleted lock.

func (*BoltDB) UnlockByPull

func (b *BoltDB) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error)

UnlockByPull deletes all locks associated with that pull request and returns them.

func (*BoltDB) UpdatePullWithResults

func (b *BoltDB) UpdatePullWithResults(pull models.PullRequest, newResults []models.ProjectResult) (models.PullStatus, error)

UpdatePullWithResults updates pull's status with the latest project results. It returns the new PullStatus object.

Jump to

Keyboard shortcuts

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