Documentation
¶
Overview ¶
Package lock serializes the writes on one repository and bounds how many run at once.
A lock is held in memory and backed by a file lock on disk, so a second gitd, or one that restarted while the first one's git was still running, waits too. Both are taken before git takes its own `.lock` files, which is what lets a stale one be told from a live one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBusy = errors.New("busy")
ErrBusy is a wait that ran out of time or room. A wait the caller gave up on returns the caller's own context error instead, so a cancelled call is not taken for a busy one.
Functions ¶
func ClearStale ¶
ClearStale removes the `.lock` files git leaves behind when it is killed, from the git directory at gitDir, once they are older than grace.
Only the files git is known to take, never any `*.lock`: something else may own one. It is called with the repository's lock held, so no git of gitd's is running there.
Types ¶
type Locks ¶
type Locks struct {
// contains filtered or unexported fields
}
Locks are the locks of one gitd, one per key, each waited for at most maxWait.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue bounds how many operations of one kind run at once and how many wait, each for at most maxWait. What does not fit is refused rather than left to pile up.