lock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2016 License: Apache-2.0 Imports: 4 Imported by: 12

Documentation

Overview

Package lock implements coordinated etcd locking across multiple locks to provide a safe experience between different parts of the volplugin system.

Currently this package coordinates create, remove, mount and snapshot locks. Snapshot locks in particular are special; they are a secondary lock that exists for remove operations only.

goroutine-safe functions to manage TTL-safe reporting also exist here.

Index

Constants

View Source
const (
	// ReasonCreate is the "create" reason for the lock
	ReasonCreate = "Create"
	// ReasonMount is the "mount" reason for the lock
	ReasonMount = "Mount"
	// ReasonRemove is the "remove" reason for the lock
	ReasonRemove = "Remove"

	// ReasonSnapshot is the "snapshot" reason for the lock
	ReasonSnapshot = "Snapshot"
	// ReasonSnapshotPrune is the prune operation for snapshots
	ReasonSnapshotPrune = "SnapshotPrune"

	// ReasonCopy indicates a copy from snapshot operation.
	ReasonCopy = "Copy"
	// ReasonMaintenance indicates that an operator is acquiring the lock.
	ReasonMaintenance = "Maintenance"
)

Variables

View Source
var (
	// ErrPublish is an error for when use locks cannot be published
	ErrPublish = errors.New("Could not publish use lock")

	// ErrRemove is an error for when use locks cannot be removed
	ErrRemove = errors.New("Could not remove use lock")

	// Unlocked is a string indicating unlocked operation, this is typically used
	// as a hostname for our locking system.
	Unlocked = "-unlocked-"
)

Functions

This section is empty.

Types

type Driver

type Driver struct {
	Config *config.Client
}

Driver is the top-level struct for lock objects

func NewDriver

func NewDriver(config *config.Client) *Driver

NewDriver creates a Driver. Requires a configured Client.

func (*Driver) ExecuteWithMultiUseLock

func (d *Driver) ExecuteWithMultiUseLock(ucs []config.UseLocker, timeout time.Duration, runFunc func(d *Driver, ucs []config.UseLocker) error) error

ExecuteWithMultiUseLock takes several UseLockers and tries to lock them all at the same time. If it fails, it returns an error. If timeout is zero, it will not attempt to retry acquiring the lock. Otherwise, it will attempt to wait for the provided timeout and only return an error if it fails to acquire them in time.

func (*Driver) ExecuteWithUseLock

func (d *Driver) ExecuteWithUseLock(uc config.UseLocker, runFunc func(d *Driver, uc config.UseLocker) error) error

ExecuteWithUseLock executes a function within a lock/context of the passed *config.UseMount.

Directories

Path Synopsis
Package client implements a client to the volmaster to acquire locks.
Package client implements a client to the volmaster to acquire locks.

Jump to

Keyboard shortcuts

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