Documentation
¶
Overview ¶
Package instancelock lets one process at a time own a resource, such as the Caddyfile that caddy-view edits.
The lock is an exclusive SQLite transaction on a small file, held on one connection for as long as the lock is held. SQLite takes the operating system's file locks for it, and the system drops them when the process ends, however it ends, so there is no stale lock to clear, no PID file and no timeout. It reuses the SQLite driver the history store already needs and works the same on Linux, macOS and Windows. It holds between processes on one machine that see the file through the same local file system; it is not meant for network file systems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("the lock is held by another process")
ErrBusy means another holder, in this process or in another, has the lock.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock is a held lock. The zero value holds nothing.
func Acquire ¶
Acquire takes the lock kept in the file at path, creating the file if needed, without waiting. It fails with ErrBusy when somebody else holds it, and with another error when the file cannot be used: its directory is missing or not writable, or the path is a symbolic link. The lock is released by Release, or by the system when the process ends.