Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FLock ¶
type FLock struct {
// contains filtered or unexported fields
}
FLock a type that supports file locking to coordinate work between processes
func New ¶
New instantiates *FLock on the given path. The path must point to a file not a directory. The file doesn't have to exist prior to calling this method. It will be creating on the first call to TryLock method.
func (*FLock) Lock ¶
ock tries to acquire an exclusive lock on a file until it succeeds, an error is returned or the context is done.
The callers MUST call the corresponding Unlock method to release the lock and associated resources except when an error is returned (including the context being done).
This method is safe for concurrent access.
Note the given context shouldn't last less than 1 second to be able to acquire the lock.
func (*FLock) TryLock ¶
TryLock tries to acquire an exclusive lock on a file until it succeeds, an error is returned or the timeout is reached.
The callers MUST call the corresponding Unlock method to release the lock and associated resources except when an error is returned (including the timeout).
This method is safe for concurrent access.
Note the given timeout shouldn't be less than 1 second.