Documentation ¶
Overview ¶
Package lock implements file system operation locks based around hierarchical `/` delimited paths.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PathLocker ¶
type PathLocker struct {
// contains filtered or unexported fields
}
PathLocker is a hierarchical path locker, inspired by Ritik Malhotra's paper on path-based locks.
func (*PathLocker) Access ¶
func (ml *PathLocker) Access(path string) UnlockFunc
Access should be used when an object's data or metadata is to be read.
func (*PathLocker) CreateOrDelete ¶
func (ml *PathLocker) CreateOrDelete(path string) UnlockFunc
CreateOrDelete should be used when an object is to be created or deleted at/from `path`.
func (*PathLocker) Modify ¶
func (ml *PathLocker) Modify(path string) UnlockFunc
Modify should be used when an object's data or metadata is to be written to.
func (*PathLocker) Move ¶
func (ml *PathLocker) Move(oldpath, newpath string) UnlockFunc
Move should be used when `oldpath` is to be moved (and optionally renamed) to a new directory.
func (*PathLocker) Rename ¶
func (ml *PathLocker) Rename(oldpath, newname string) UnlockFunc
Rename should be used when 'oldpath' is to be renamed within its parent directory.
type UnlockFunc ¶
type UnlockFunc = func()
UnlockFunc must be called after an operation completes. Typically a single defer statement is used to acquire and later release a lock from a PathLocker.
defer locker.Operation(args...)()