v3.4.0 593c1c3

state.go RawHistoryFolder

1// Package registrystate coordinates registry mutations and garbage collection.
2package registrystate
3
4import (
5	"sync"
6	"time"
7)
8
9// PendingBlobTTL protects uploaded blobs while clients publish their manifest.
10const PendingBlobTTL = 24 * time.Hour
11
12// State is shared by registry writes and registry garbage collection.
13type State struct {
14	MutationMu sync.RWMutex
15
16	pendingMu sync.Mutex
17	pending   map[string]time.Time
18}
19
20// New creates empty registry coordination state.
21func New() *State {
22	return &State{pending: make(map[string]time.Time)}
23}
24
25// AddPending records a blob that has been uploaded but not yet referenced by a manifest.
26func (s *State) AddPending(digest string, now time.Time) {
27	s.pendingMu.Lock()
28	defer s.pendingMu.Unlock()
29	if s.pending == nil {
30		s.pending = make(map[string]time.Time)
31	}
32	s.pending[digest] = now
33}
34
35// MarkPublished removes blobs now owned by a published manifest from the pending set.
36func (s *State) MarkPublished(digests []string) {
37	s.pendingMu.Lock()
38	defer s.pendingMu.Unlock()
39	for _, digest := range digests {
40		delete(s.pending, digest)
41	}
42}
43
44// PendingDigests returns non-expired pending blobs and drops abandoned entries.
45func (s *State) PendingDigests(now time.Time) map[string]struct{} {
46	s.pendingMu.Lock()
47	defer s.pendingMu.Unlock()
48	result := make(map[string]struct{}, len(s.pending))
49	for digest, createdAt := range s.pending {
50		if now.Sub(createdAt) > PendingBlobTTL {
51			delete(s.pending, digest)
52			continue
53		}
54		result[digest] = struct{}{}
55	}
56	return result
57}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close