detached 844c846

feat(clock): real ports.Clock adapter over time.Timer

commit
844c8460f79c67cab0df821e4c47ac9c881ef0a6
author
brice · · 2026-07-02 11:59 UTC
parent
4ab7e23
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +30 -0
A internal/adapters/clock/clock.go +30 -0
@@ -0,0 +1,30 @@
1+// Package clock provides the production ports.Clock: a thin wrapper over the
2+// standard library's time package. Usecases depend on ports.Clock so their
3+// time-dependent logic (the daemon's debounced render scheduler) can be driven
4+// deterministically in tests via mocks, while the app wires this real clock.
5+package clock
6+
7+import (
8+ "time"
9+
10+ "github.com/bnema/vev/internal/ports"
11+)
12+
13+// realClock implements ports.Clock over the wall clock.
14+type realClock struct{}
15+
16+// New returns the production ports.Clock.
17+func New() ports.Clock { return realClock{} }
18+
19+func (realClock) Now() time.Time { return time.Now() }
20+
21+func (realClock) NewTimer(d time.Duration) ports.Timer {
22+ return &realTimer{t: time.NewTimer(d)}
23+}
24+
25+// realTimer adapts *time.Timer to ports.Timer.
26+type realTimer struct{ t *time.Timer }
27+
28+func (r *realTimer) C() <-chan time.Time { return r.t.C }
29+func (r *realTimer) Reset(d time.Duration) bool { return r.t.Reset(d) }
30+func (r *realTimer) Stop() bool { return r.t.Stop() }
@@ -0,0 +1,30 @@
1+// Package clock provides the production ports.Clock: a thin wrapper over the
2+// standard library's time package. Usecases depend on ports.Clock so their
3+// time-dependent logic (the daemon's debounced render scheduler) can be driven
4+// deterministically in tests via mocks, while the app wires this real clock.
5+package clock
6+
7+import (
8+ "time"
9+
10+ "github.com/bnema/vev/internal/ports"
11+)
12+
13+// realClock implements ports.Clock over the wall clock.
14+type realClock struct{}
15+
16+// New returns the production ports.Clock.
17+func New() ports.Clock { return realClock{} }
18+
19+func (realClock) Now() time.Time { return time.Now() }
20+
21+func (realClock) NewTimer(d time.Duration) ports.Timer {
22+ return &realTimer{t: time.NewTimer(d)}
23+}
24+
25+// realTimer adapts *time.Timer to ports.Timer.
26+type realTimer struct{ t *time.Timer }
27+
28+func (r *realTimer) C() <-chan time.Time { return r.t.C }
29+func (r *realTimer) Reset(d time.Duration) bool { return r.t.Reset(d) }
30+func (r *realTimer) Stop() bool { return r.t.Stop() }

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