boltdb

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2017 HootSuite Media Inc.

Licensed under the Apache License, Version 2.0 (the License); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Modified hereafter by contributors to runatlantis/atlantis.

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