detached e0d4819

refactor(busretry): unexport the maximum retry delay

commit
e0d48191cb0f344db37cc6476d5b4db6a5897d9c
author
brice · · 2026-10-08 09:02 UTC
parent
508f6f4
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +7 -7
M internal/adapters/busretry/busretry.go +6 -6
@@ -11,12 +11,12 @@ import (
1111 "github.com/bnema/zerowrap"
1212 )
1313
14-// Max bounds the delay between attempts.
15-const Max = time.Minute
14+// maxDelay bounds the delay between attempts.
15+const maxDelay = time.Minute
1616
1717 // Run calls attempt until ctx ends. When attempt returns, it waits retry,
18-// doubling up to Max on each failure, and calls it again. An attempt that
19-// ran longer than Max before failing starts the delay over: its failure is
18+// doubling up to maxDelay on each failure, and calls it again. An attempt that
19+// ran longer than maxDelay before failing starts the delay over: its failure is
2020 // new, not a retry streak. what names the feature in logs ("X ignored until
2121 // the next attempt"); a failure is warned once per distinct error, then
2222 // logged at debug level.
@@ -32,7 +32,7 @@ func Run(ctx context.Context, retry time.Duration, what string, log zerowrap.Log
3232 if err == nil {
3333 err = errors.New(what + " stopped")
3434 }
35- if time.Since(start) > Max {
35+ if time.Since(start) > maxDelay {
3636 delay, last = retry, ""
3737 }
3838 if msg := err.Error(); msg != last {
@@ -46,6 +46,6 @@ func Run(ctx context.Context, retry time.Duration, what string, log zerowrap.Log
4646 return
4747 case <-time.After(delay):
4848 }
49- delay = min(2*delay, Max)
49+ delay = min(2*delay, maxDelay)
5050 }
5151 }
@@ -11,12 +11,12 @@ import (
11 "github.com/bnema/zerowrap"11 "github.com/bnema/zerowrap"
12 )12 )
13 13
14-// Max bounds the delay between attempts.14+// maxDelay bounds the delay between attempts.
15-const Max = time.Minute15+const maxDelay = time.Minute
16 16
17 // Run calls attempt until ctx ends. When attempt returns, it waits retry,17 // Run calls attempt until ctx ends. When attempt returns, it waits retry,
18-// doubling up to Max on each failure, and calls it again. An attempt that18+// doubling up to maxDelay on each failure, and calls it again. An attempt that
19-// ran longer than Max before failing starts the delay over: its failure is19+// ran longer than maxDelay before failing starts the delay over: its failure is
20 // new, not a retry streak. what names the feature in logs ("X ignored until20 // new, not a retry streak. what names the feature in logs ("X ignored until
21 // the next attempt"); a failure is warned once per distinct error, then21 // the next attempt"); a failure is warned once per distinct error, then
22 // logged at debug level.22 // logged at debug level.
@@ -32,7 +32,7 @@ func Run(ctx context.Context, retry time.Duration, what string, log zerowrap.Log
32 if err == nil {32 if err == nil {
33 err = errors.New(what + " stopped")33 err = errors.New(what + " stopped")
34 }34 }
35- if time.Since(start) > Max {35+ if time.Since(start) > maxDelay {
36 delay, last = retry, ""36 delay, last = retry, ""
37 }37 }
38 if msg := err.Error(); msg != last {38 if msg := err.Error(); msg != last {
@@ -46,6 +46,6 @@ func Run(ctx context.Context, retry time.Duration, what string, log zerowrap.Log
46 return46 return
47 case <-time.After(delay):47 case <-time.After(delay):
48 }48 }
49- delay = min(2*delay, Max)49+ delay = min(2*delay, maxDelay)
50 }50 }
51 }51 }
M internal/adapters/screensaver/screensaver.go +1 -1
@@ -53,7 +53,7 @@ type Reports struct {
5353
5454 // Serve runs the service until ctx ends. When the bus goes or another
5555 // program owns the name, it tries again after retry, doubling up to
56-// busretry.Max, so a restarted bus or a released name is picked up.
56+// a minute, so a restarted bus or a released name is picked up.
5757 func Serve(ctx context.Context, address string, r Reports, retry time.Duration, log zerowrap.Logger) {
5858 busretry.Run(ctx, retry, "D-Bus idle inhibitors", log, func(ctx context.Context) error {
5959 s, err := New(ctx, address, log)
@@ -53,7 +53,7 @@ type Reports struct {
53 53
54 // Serve runs the service until ctx ends. When the bus goes or another54 // Serve runs the service until ctx ends. When the bus goes or another
55 // program owns the name, it tries again after retry, doubling up to55 // program owns the name, it tries again after retry, doubling up to
56-// busretry.Max, so a restarted bus or a released name is picked up.56+// a minute, so a restarted bus or a released name is picked up.
57 func Serve(ctx context.Context, address string, r Reports, retry time.Duration, log zerowrap.Logger) {57 func Serve(ctx context.Context, address string, r Reports, retry time.Duration, log zerowrap.Logger) {
58 busretry.Run(ctx, retry, "D-Bus idle inhibitors", log, func(ctx context.Context) error {58 busretry.Run(ctx, retry, "D-Bus idle inhibitors", log, func(ctx context.Context) error {
59 s, err := New(ctx, address, log)59 s, err := New(ctx, address, log)

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 25

Tags 10

↑↓ moveenter openesc close