Documentation
¶
Overview ¶
Package sharedwire is the relay side of the shared runner: how a session a client started reaches the one runner that serves every session on this machine, and how the session's messages pass between them.
It uses only the standard library, so the relay built from it (./relay) stays a few megabytes: a client keeps one relay per session for as long as the session is open, and some clients keep dozens.
Index ¶
- Variables
- func Detach(cmd *exec.Cmd)
- func Dial(p Paths, runner string) (net.Conn, error)
- func LockFile(f *os.File) error
- func Relay(in io.Reader, out io.Writer, p Paths, runner string, h Hello) error
- func SendHello(c net.Conn, r *bufio.Reader, h Hello) error
- func StartRunner(p Paths, runner string) error
- func TryLockFile(f *os.File) error
- type Answer
- type Hello
- type Paths
Constants ¶
This section is empty.
Variables ¶
var Dir = func() (string, error) { base, err := os.UserCacheDir() if err != nil { return "", err } return filepath.Join(base, "tap-runtime", "shared"), nil }
Dir is where the runner keeps its socket, lock and log: private to this user. A variable so a test can move it.
ErrNoShared is returned, wrapped, when no runner can be reached.
var Logf = func(format string, a ...any) { fmt.Fprintf(os.Stderr, "tap "+format+"\n", a...) }
Logf writes a line of the relay's own log, to standard error.
Functions ¶
func Detach ¶
Detach starts cmd in a session of its own, so it outlives the agent session that started it and no signal to that session reaches it.
func LockFile ¶
LockFile waits for an exclusive lock on f. The lock is released when f is closed or the process ends, so a crashed holder never keeps it.
func Relay ¶
Relay passes one client session, read from in and answered on out, to the runner. It returns ErrNoShared, wrapped and having read nothing from in, when no runner can be reached.
func StartRunner ¶
StartRunner starts runner shared-runner, detached from this session. Several relays may start one at once; all but the first find the runner's lock taken and stop.
func TryLockFile ¶
TryLockFile takes an exclusive lock on f, or fails at once if another process holds it.