v0.2.0 80c61e3

health.go RawHistoryFolder

1package dgram
2
3import (
4	"time"
5
6	"github.com/bnema/vev/internal/ports"
7)
8
9// healthTracker separates authenticated path contact from useful stream
10// progress. Transport.mu protects every field.
11type healthTracker struct {
12	lastPacket   time.Time
13	lastRecord   time.Time
14	lastProgress time.Time
15	pendingSince time.Time
16	generation   uint64
17}
18
19func newHealthTracker(now time.Time) healthTracker {
20	return healthTracker{lastPacket: now, lastRecord: now, lastProgress: now}
21}
22
23func (h *healthTracker) authenticatedPacket(now time.Time) {
24	h.lastPacket = now
25	h.generation++
26}
27
28func (h *healthTracker) completeRecord(now time.Time) {
29	h.lastRecord = now
30	h.generation++
31}
32
33func (h *healthTracker) ackProgress(now time.Time) {
34	h.lastProgress = now
35	h.generation++
36}
37
38func (h *healthTracker) pendingStarted(now time.Time) {
39	h.pendingSince = now
40	h.generation++
41}
42
43func (h *healthTracker) pendingCleared() {
44	h.pendingSince = time.Time{}
45	h.generation++
46}
47
48func (h healthTracker) decide(now time.Time, hasPending bool, degradedAfter, probeAfter, offlineAfter, deadAfter time.Duration) (ports.LinkState, bool, bool) {
49	packetAge := now.Sub(h.lastPacket)
50	switch {
51	case deadAfter > 0 && packetAge >= deadAfter:
52		return ports.LinkStateDead, false, true
53	case offlineAfter > 0 && packetAge >= offlineAfter:
54		return ports.LinkStateOffline, false, false
55	case probeAfter > 0 && packetAge >= probeAfter:
56		return ports.LinkStateProbing, true, false
57	}
58
59	qualityAt := h.lastRecord
60	if h.lastProgress.After(qualityAt) {
61		qualityAt = h.lastProgress
62	}
63	qualityAge := now.Sub(qualityAt)
64	if hasPending && probeAfter > 0 {
65		pendingBaseline := h.pendingSince
66		if pendingBaseline.IsZero() || h.lastProgress.After(pendingBaseline) {
67			pendingBaseline = h.lastProgress
68		}
69		if now.Sub(pendingBaseline) >= probeAfter {
70			return ports.LinkStateProbing, true, false
71		}
72	}
73	if degradedAfter > 0 && qualityAge >= degradedAfter {
74		return ports.LinkStateDegraded, false, false
75	}
76	return ports.LinkStateConnected, false, false
77}

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 12

Tags 11

↑↓ moveenter openesc close