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 ¶
func TryLock(lockName string) UnlockFunc
TryLock attempts to acquire a lock without blocking. If it succeeds it returns an unlock function. If it fails it returns nil.
Click to show internal directories.
Click to hide internal directories.