boltdb

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package boltdb provides a locking implementation using Bolt. Bolt is a key/value store that writes all data to a file. See https://github.com/boltdb/bolt for more information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltLocker

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

BoltLocker is a locking backend using BoltDB

func New

func New(dataDir string) (*BoltLocker, 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) (*BoltLocker, error)

NewWithDB is used for testing.

func (BoltLocker) GetLock

func (b BoltLocker) 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 (BoltLocker) List

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

List lists all current locks.

func (*BoltLocker) TryLock

func (b *BoltLocker) 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 (BoltLocker) Unlock

func (b BoltLocker) 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 (BoltLocker) UnlockByPull

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

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

Jump to

Keyboard shortcuts

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