Documentation
¶
Overview ¶
Package dlock is a distributed lock to enable advanced synchronization for Mattermost Plugins.
if you're new to distributed locks and Mattermost Plugins please read sample use case scenarios at: https://community.mattermost.com/core/pl/bb376sjsdbym8kj7nz7zrcos7r
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCouldntObtainImmediately returned when a lock couldn't be obtained immediately after // calling Lock(). ErrCouldntObtainImmediately = errors.New("could not obtain immediately") )
Functions ¶
This section is empty.
Types ¶
type DLock ¶
type DLock struct {
// contains filtered or unexported fields
}
DLock is a distributed lock.
func New ¶
New creates a new distributed lock for key on given store with options. think,
`dl := New("my-key", store)`
as an equivalent of,
`var m sync.Mutex`
and use it in the same way.
func (*DLock) Lock ¶
Lock obtains a new lock. ctx provides a context to locking. when ctx is cancelled, Lock() will stop blocking and retries and return with error. use Lock() exactly like sync.Mutex.Lock(), avoid missuses like deadlocks.
Click to show internal directories.
Click to hide internal directories.