locks

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TIME_FORMAT = "2006-01-02 15:04:05.999999999 -0700 MST"

Copied from format.go. Not sure why it's not exposed as a variable.

Variables

View Source
var NoIpAddressFound = fmt.Errorf("Could not find IP address for current machine")

Functions

func WithLock

func WithLock(lock Lock, action func() error) (finalErr error)

Acquire a lock, execute the given function, and release the lock

Types

type Lock

type Lock interface {
	// Acquire a lock
	AcquireLock() error

	// Release a lock
	ReleaseLock() error

	// Print a string representation of the lock
	String() string
}

Every type of lock must implement this interface

type LockMetadata

type LockMetadata struct {
	StateFileId string
	Username    string
	IpAddress   string
	DateCreated time.Time
}

This structure represents useful metadata about the lock, such as who acquired it, when, and from what IP

func CreateLockMetadata

func CreateLockMetadata(stateFileId string, username string) (*LockMetadata, error)

Create the LockMetadata for the given state file and user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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