mutex

package
v0.0.0-...-93d971c Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidArgumentError = errgo.New("invalid argument")
	AlreadyLockedError   = errgo.New("already locked")
	NotLockedError       = errgo.New("not locked yet")
	NotOwnerError        = errgo.New("not owner")
	AlreadyUsedError     = errgo.New("cannot claim lock twice")
)

Functions

func IsAlreadyLocked

func IsAlreadyLocked(err error) bool

func IsAlreadyUsed

func IsAlreadyUsed(err error) bool

func IsInvalidArgument

func IsInvalidArgument(err error) bool

func IsNotLocked

func IsNotLocked(err error) bool

func IsNotOwner

func IsNotOwner(err error) bool

Types

type GlobalMutex

type GlobalMutex struct {
	// contains filtered or unexported fields
}

func (*GlobalMutex) Lock

func (gm *GlobalMutex) Lock() error

Lock tries to claim the given mutex. If successful, it returns nil, otherwise it returns an error. If the mutex is already locked, it returns directly with nil.

func (*GlobalMutex) Locked

func (gm *GlobalMutex) Locked() bool

Locked returns true if this lock is claimed successfully.

func (*GlobalMutex) Unlock

func (gm *GlobalMutex) Unlock() error

Unlock releases the given mutex. If the mutex was not locked, it returns nil right away.

type GlobalMutexService

type GlobalMutexService interface {
	// New creates a new global mutex with a given name.
	// The mutex is initialized but not yet claimed.
	// name is the name of the new mutex. This name is accessible globally in the cluster
	// ttl is the amount of time before the mutex will automatically be released
	New(name string, ttl time.Duration) (*GlobalMutex, error)
}

func NewEtcdGlobalMutexService

func NewEtcdGlobalMutexService(etcdClient client.Client, prefix string) GlobalMutexService

NewEtcdGlobalMutexService returns a global mutex service implementation based on ETCD.

Jump to

Keyboard shortcuts

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