Documentation ¶
Overview ¶
Package lock - implements filesystem locking wrappers around an open file descriptor.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyLocked = errors.New("file already locked")
ErrAlreadyLocked is returned if the underlying fd is already locked.
Functions ¶
Types ¶
type LockedFile ¶
LockedFile represents a locked file
func LockedOpenFile ¶
LockedOpenFile - initializes a new lock and protects the file from concurrent access across mount points. This implementation doesn't support all the open flags and shouldn't be considered as replacement for os.OpenFile().
func TryLockedOpenFile ¶
TryLockedOpenFile - tries a new write lock, functionality it is similar to LockedOpenFile with with syscall.LOCK_EX mode but along with syscall.LOCK_NB such that the function doesn't wait forever but instead returns if it cannot acquire a write lock.
type RLockedFile ¶
type RLockedFile struct { *LockedFile // contains filtered or unexported fields }
RLockedFile represents a read locked file, implements a special closer which only closes the associated *os.File when the ref count. has reached zero, i.e when all the readers have given up their locks.
func RLockedOpenFile ¶
func RLockedOpenFile(path string) (*RLockedFile, error)
RLockedOpenFile - returns a wrapped read locked file, if the file doesn't exist at path returns an error.
func (*RLockedFile) Close ¶
func (r *RLockedFile) Close() (err error)
Close - this closer implements a special closer closes the underlying fd only when the refs reach zero.
func (*RLockedFile) IncLockRef ¶
func (r *RLockedFile) IncLockRef()
IncLockRef - is used by called to indicate lock refs.
func (*RLockedFile) IsClosed ¶
func (r *RLockedFile) IsClosed() bool
IsClosed - Check if the rlocked file is already closed.