Help us shape the future of Go! Take the 2026 Go Developer Survey

storelock

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package storelock keeps two DriftGate processes from writing one local store at the same time: two worktrees of a project share the store, and a capture in one would otherwise move aside, replace or remove the other's capture of the same tag. The lock is advisory, a lock on <store>/.lock that the system releases when the process ends, also when it is killed; the file itself stays and holds the process ID of the last holder.

Index

Constants

View Source
const FileName = ".lock"

FileName is the lock file in the store.

Variables

This section is empty.

Functions

func Acquire

func Acquire(ctx context.Context, dir string, busy func(pid int)) (release func(), err error)

Acquire takes the lock of the store dir, waiting while another process holds it; busy, when set, is called once before the wait with the other process's ID (0 when unknown). The wait ends with ctx. release gives the lock back.

func Holder

func Holder(dir string) int

Holder is the process ID written in the lock file of dir: the process that holds the lock, or held it last; 0 when unknown.

Types

This section is empty.

Jump to

Keyboard shortcuts

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