feat/data-dnd e05cb15

busretry.go RawHistoryFolder

1// Package busretry keeps a D-Bus service running across bus restarts and
2// busy names: it runs an attempt again after a growing delay until the
3// context ends.
4package busretry
5
6import (
7	"context"
8	"errors"
9	"time"
10
11	"github.com/bnema/zerowrap"
12)
13
14// maxDelay bounds the delay between attempts.
15const maxDelay = time.Minute
16
17// Run calls attempt until ctx ends. When attempt returns, it waits retry,
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
20// 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, then
22// logged at debug level.
23func Run(ctx context.Context, retry time.Duration, what string, log zerowrap.Logger, attempt func(context.Context) error) {
24	delay := retry
25	var last string
26	for {
27		start := time.Now()
28		err := attempt(ctx)
29		if ctx.Err() != nil {
30			return
31		}
32		if err == nil {
33			err = errors.New(what + " stopped")
34		}
35		if time.Since(start) > maxDelay {
36			delay, last = retry, ""
37		}
38		if msg := err.Error(); msg != last {
39			last = msg
40			log.Warn().Err(err).Dur("retry", delay).Msg(what + " ignored until the next attempt")
41		} else {
42			log.Debug().Err(err).Dur("retry", delay).Msg(what + " still ignored")
43		}
44		select {
45		case <-ctx.Done():
46			return
47		case <-time.After(delay):
48		}
49		delay = min(2*delay, maxDelay)
50	}
51}

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