lock

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock is used to ensure only one agent has permission to do certain operations. It relies on creating files

func New

func New(path string) *Lock

New returns a Lock instance, it does not try to acquire the lock yet, so no file will be created until Acquire() is called.

func (*Lock) Acquire

func (l *Lock) Acquire() (err error)

Acquire attempts to lock the file. This operation blocks as long as needed until it can be acquired.

func (*Lock) Release

func (l *Lock) Release() error

Release the lock that was acquired.

func (*Lock) WithPeriod

func (l *Lock) WithPeriod(period time.Duration) *Lock

WithPeriod configures the polling period during lock acquisition, for purposes of printing the warning message.

func (*Lock) WithWarn

func (l *Lock) WithWarn(warn string) *Lock

WithWarn configures the warning message that will be printed on slow lock acquisition.

Jump to

Keyboard shortcuts

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