filelock

package
v0.0.0-...-6ec7e1c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package filelock provides the resources required to create a file lock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLock

type FileLock struct {
	// contains filtered or unexported fields
}

FileLock represents a lock for a key stored as a single file.

func New

func New(baseURI storage.Path, key string, opts Options) *FileLock

New creates a new FileLock instance.

func (*FileLock) NewLock

func (l *FileLock) NewLock(key string) (lock.Locker, error)

NewLock creates a new FileLock instance using an existing FileLock instance.

func (*FileLock) TryLock

func (l *FileLock) TryLock() (acquiredLock bool, returnErr error)

TryLock attempts to acquire a file lock.

func (*FileLock) Unlock

func (l *FileLock) Unlock() error

Unlock releases a file lock.

type Options

type Options struct {
	// The amount of time (in seconds) that the owner has this lock for.
	// If lease_duration is None then the lock is non-expirable.
	TTL time.Duration
	// Block=true sets the behavior of TryLock() to blocking, if Block=false TryLock() will
	// be non-blocking and will return false if the lock is currently held by a different client
	Block           bool
	DeleteOnRelease bool
}

Options contains settings that can be adjusted to change the behavior of a file lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL