Documentation ¶
Index ¶
- type ExclusiveLock
- type FSLocker
- func (locker *FSLocker) ExclusiveLock(ctx context.Context, path string, timeout *time.Duration) (*ExclusiveLock, error)
- func (locker *FSLocker) ListFiles(path string) ([]Record, error)
- func (locker *FSLocker) RemovePath(path string) error
- func (locker *FSLocker) SharedLock(ctx context.Context, path string, timeout *time.Duration) (*SharedLock, error)
- type Lock
- type Record
- type SharedLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExclusiveLock ¶
type ExclusiveLock struct {
*Lock
}
ExclusiveLock represents the state of a Exclusive Lock
func (*ExclusiveLock) ToSharedLock ¶
func (el *ExclusiveLock) ToSharedLock() *SharedLock
ToSharedLock downgrade an ExclusiveLock into a SharedLock. It should always succeed
type FSLocker ¶
type FSLocker struct {
// contains filtered or unexported fields
}
FSLocker is a configuration holder struct, use NewFSLocker to instantiate
func NewFSLocker ¶
NewFSLocker instantiates a new FSLocker instance
func (*FSLocker) ExclusiveLock ¶
func (locker *FSLocker) ExclusiveLock(ctx context.Context, path string, timeout *time.Duration) (*ExclusiveLock, error)
ExclusiveLock tries to get an exclusive Lock on the path If timeout is nil, then this function will be blocking until lock acquisition is successful if timeout is 0, it will be non-blocking and return unix.EWOULDBLOCK if we cannot acquire the lock if timeout is non-zero, and we timeout, it will return unix.ETIMEDOUT
func (*FSLocker) RemovePath ¶
RemovePath removes a given path. It requires that there are no subdirectories. It does not ensure the file is not in used
func (*FSLocker) SharedLock ¶
func (locker *FSLocker) SharedLock(ctx context.Context, path string, timeout *time.Duration) (*SharedLock, error)
SharedLock tries to get an shared Lock on the path If timeout is nil, then this function will be blocking until lock acquisition is successful if timeout is 0, it will be non-blocking and return unix.EWOULDBLOCK if we cannot acquire the lock if timeout is non-zero, and we timeout, it will return unix.ETIMEDOUT
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is either a shared lock, or an exclusive lock.
type SharedLock ¶
type SharedLock struct {
}SharedLock represents the state of a Shared Lock
func (*SharedLock) ToExclusiveLock ¶
func (sl *SharedLock) ToExclusiveLock(ctx context.Context, timeout *time.Duration) (*ExclusiveLock, error)
ToExclusiveLock tries to upgrade a SharedLock into an ExclusiveLock. If timeout is nil, then this function will be blocking, otherwise it will be non-blocking. It will return unix.ETIMEDOUT if timeout occurs If timeout is 0