Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UnlockFunc ¶
type UnlockFunc func()
UnlockFunc unlocks the lock.
func Lock ¶
func Lock(ctx context.Context, lockName string) (UnlockFunc, error)
Lock creates a named lock to allow activities that require exclusive access to occur. Will block until the lock is established or the context is cancelled. On successfully acquiring the lock, it returns an unlock function which needs to be called to unlock the lock. If the context is canceled then nil will be returned.
func TryLock ¶ added in v7.1.0
func TryLock(lockName string) (UnlockFunc, chan struct{})
TryLock creates a named lock for activities that require exclusive access. It does not block if the lock is already held. If the lock is acquired successfully, it returns an unlock function that must be called to release the lock.
Click to show internal directories.
Click to hide internal directories.