Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultLockTimeout is the default lock timeout. DefaultLockTimeout = 3 * time.Second // DefaultLockRetryDelay is the default lock retry delay. DefaultLockRetryDelay = 200 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LockOption ¶
type LockOption func(*lockOptions)
LockOption is an option for lock.
func LockWithRetryDelay ¶
func LockWithRetryDelay(retryDelay time.Duration) LockOption
LockWithRetryDelay returns a new LockOption that sets the lock retry delay.
Lock will try to lock on this delay up until the lock timeout.
func LockWithTimeout ¶
func LockWithTimeout(timeout time.Duration) LockOption
LockWithTimeout returns a new LockOption that sets the lock timeout.
Lock returns error if the lock cannot be acquired after this amount of time. If this is set to 0, the lock will never timeout.
type Locker ¶
type Locker interface { // Lock locks a file lock within the root directory of the Locker. // // The given path must be normalized and relative. Lock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) // RLock read-locks a file lock within the root directory of the Locker. // // The given path must be normalized and relative. RLock(ctx context.Context, path string, options ...LockOption) (Unlocker, error) }
Locker provides file locks.
Click to show internal directories.
Click to hide internal directories.