flock

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: MIT Imports: 6 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta added in v1.1.0

type Meta struct {
	At        time.Time `json:"at"`
	PID       int       `json:"pid"`
	Intent    string    `json:"intent"`
	SessionID string    `json:"session_id"`
}

type T

type T struct {
	locker.Locker
	Path string
	// contains filtered or unexported fields
}

T wraps flock and dumps JSON data in the lock file hinting about what holds the lock.

func New

func New(p string, sessionId string, lockP func(string) locker.Locker) *T

New allocate a file lock struct from the Locker provider.

func (*T) Lock

func (t *T) Lock(timeout time.Duration, intent string) (err error)

Lock acquires an exclusive file lock on the file and writes a JSON formatted structure hinting who holds the lock and with what intention.

func (*T) Probe added in v1.1.0

func (t *T) Probe(intent string) (m Meta, err error)

func (*T) UnLock

func (t *T) UnLock() error

UnLock releases the file lock acquired by Lock.

Jump to

Keyboard shortcuts

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