Documentation
¶
Overview ¶
Package lock provides an interface for file-based locking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrLockExists = errors.New("lock already exists") ErrLockStale = errors.New("stale lock detected") ErrLockLost = errors.New("lock lost") ErrLockAcquire = errors.New("failed to acquire lock") ErrLockContextCancelled = errors.New("context was cancelled while obtaining the lock") ErrLockCorrup = errors.New("corrupt lock file") ErrMaxRetryExceeded = errors.New("failed to acquire lock, max retries exceeded") DefaultStaleTimeout = time.Millisecond * 500 DefaultRefreshInterval = time.Millisecond * 200 DefaultRetryInterval = 1 * time.Second DefaultMaxRetry = 5 )
Functions ¶
Types ¶
type FileLock ¶
type FileLock struct {
// contains filtered or unexported fields
}
func NewFileLock ¶
func NewFileLock(ctx context.Context, filepath string, opts ...FileLockOption) *FileLock
type FileLockOption ¶
type FileLockOption func(fl *FileLock)
func WithMaxRetry ¶
func WithMaxRetry(retry int) FileLockOption
func WithNoMaxRetry ¶
func WithNoMaxRetry() FileLockOption
func WithRefreshInterval ¶
func WithRefreshInterval(interval time.Duration) FileLockOption
func WithRetryInterval ¶
func WithRetryInterval(interval time.Duration) FileLockOption
func WithStaleTimeout ¶
func WithStaleTimeout(timeout time.Duration) FileLockOption
Click to show internal directories.
Click to hide internal directories.