v0.6.0 aba298d

cache.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package sandbox
4
5import (
6	"net"
7
8	"bnema.dev/ermite-runner/internal/cachesvc"
9)
10
11// ServeCache serves the runner's cache service (Config.Cache, when set) on a
12// Unix socket at path, the host end of the cache channel of sandbox id. The
13// guest relay opens one connection to it per TCP connection it accepts on its
14// loopback: through the sandbox's own bind mount (container) or through
15// Firecracker's vsock proxy (VM, which connects to <uds>_<port> when the guest
16// connects to the host on that port). Nothing but that sandbox can reach the
17// path, and the service accepts on it only tokens made for spec.JobID (see
18// cachesvc.Service.Serve). spec.Results, when set, is served on the same
19// channel beside the cache (cachesvc.WithResults). own, when not nil, sets the owner and mode of the
20// socket before it is served. mbit caps the channel's traffic, all its
21// connections and both directions together (0: unlimited); a VM passes its
22// NetMbit, as the cache stream does not cross eth0, which carries that limit.
23// With no cache service this does nothing.
24func (c Config) ServeCache(id, path string, spec JobSpec, mbit int, own func(path string) error) error {
25	if c.Cache == nil {
26		return nil
27	}
28	ln, err := net.Listen("unix", path)
29	if err != nil {
30		return err
31	}
32	if own != nil {
33		if err := own(path); err != nil {
34			_ = ln.Close()
35			return err
36		}
37	}
38	opts := []cachesvc.ServeOption{cachesvc.WithBandwidth(mbit)}
39	if spec.Results != nil {
40		opts = append(opts, cachesvc.WithResults(spec.Results))
41	}
42	return c.Cache.Serve(id, ln, spec.JobID, opts...)
43}
44
45// StopCache ends the cache channel of sandbox id: it closes the listener (which
46// removes the socket) and the open connections. It is idempotent.
47func (c Config) StopCache(id string) {
48	if c.Cache != nil {
49		c.Cache.Stop(id)
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 4

Tags 11

↑↓ moveenter openesc close