locker

package
v0.0.0-...-16a880a Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: MPL-2.0 Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLockHeld is returned if we attempt to double locker
	ErrLockHeld = fmt.Errorf("lock already held")

	// ErrLockNotHeld is returned if we attempt to unlock a locker
	// that we do not hold.
	ErrLockNotHeld = fmt.Errorf("lock not held")

	// ErrLockCancelled is returned when attempt to lock is cancelled.
	ErrLockCancelled = fmt.Errorf("lock cancelled")
)

Functions

func LockCancelled

func LockCancelled(name string) error

LockCancelled returns error for cancelled lock.

Types

type Locker

type Locker interface {
	// Key returns the name of locker.
	Key() string

	// Lock attempts to acquire the locker and blocks while doing so.
	// Providing a non-nil stopCh can be used to abort the locker attempt.
	// Returns a channel that is closed if our locker is lost or an error.
	// This channel could be closed at any time due to session invalidation,
	// communication errors, operator intervention, etc. It is NOT safe to
	// assume that the locker is held until Unlock(), application must be able
	// to handle the locker being lost.
	Lock(stopCh <-chan struct{}) (<-chan struct{}, error)

	// Unlock released the locker. It is an error to call this
	// if the locker is not currently held.
	Unlock() error
}

Locker is an interface of distributed locker.

Jump to

Keyboard shortcuts

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