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 ¶
- type BoltLocker
- func (b BoltLocker) GetLock(p models.Project, workspace string) (*models.ProjectLock, error)
- func (b BoltLocker) List() ([]models.ProjectLock, error)
- func (b *BoltLocker) TryLock(newLock models.ProjectLock) (bool, models.ProjectLock, error)
- func (b BoltLocker) Unlock(p models.Project, workspace string) (*models.ProjectLock, error)
- func (b BoltLocker) UnlockByPull(repoFullName string, pullNum int) ([]models.ProjectLock, error)
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.