lockfile

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package lockfile implements a pid lock file mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockFunc

type LockFunc func(ctx context.Context) (unlock func(), err error)

LockFunc is a function that encapsulates locking and unlocking.

type Lockfile

type Lockfile string

Lockfile is a pid file which can be locked.

func New

func New(fp string) (Lockfile, error)

New returns a new Lockfile instance. Arg fp must be an absolute path (but it's legal for the path to not exist).

func (Lockfile) Lock

func (l Lockfile) Lock(ctx context.Context, timeout time.Duration) error

Lock attempts to acquire the lock, retrying if necessary, until the timeout expires. If timeout is zero, retry will not occur. On success, nil is returned. An error is returned if the lock cannot be acquired for any reason.

func (Lockfile) String

func (l Lockfile) String() string

String returns the Lockfile's absolute path.

func (Lockfile) Unlock

func (l Lockfile) Unlock() error

Unlock a lock, if we owned it. Returns any error that happened during release of lock.

Jump to

Keyboard shortcuts

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