sock

package
v1.32.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sock is the fleet's socket-path scheme, in one place.

A service NAME maps to exactly one path — <Dir()>/<name>.sock — and both halves of every connection use this mapping, which is what keeps them from drifting: a service serves at that path and a caller dials it by name, with no registry and no discovery service in between.

It lives down here, below zip, because zip is not the only caller any more. zip.RuntimeDir and zip.SocketPath are the public spelling of it, and the telemetry exporter needs the same answer without importing zip — which it cannot do, since zip imports the exporter. A second copy of the rule would be a fleet where a program serves at one path and its telemetry looks for another.

Index

Constants

View Source
const DirEnv = "ZIP_RUNTIME_DIR"

DirEnv names the directory holding one socket per service. It is the one knob in the scheme.

View Source
const Max = 103

Max is how long a socket path may be. sun_path is a fixed-size field inside the address struct — 104 bytes on Darwin, 108 on Linux — and it holds a TERMINATED string, so the usable length is one less than the field: 103 and 107. The smaller is the one number here, so an address that binds on Darwin binds on Linux.

Measured, not read off a header: on Darwin a 103-byte path binds and a 104-byte path fails. Off by one here is not a rounding error — it is a plugin that starts everywhere except the one machine whose temp directory is a byte longer.

Variables

This section is empty.

Functions

func Dir

func Dir() string

Dir is the directory that holds the fleet's sockets, resolved in one order:

$ZIP_RUNTIME_DIR        set explicitly — always wins
$XDG_RUNTIME_DIR/zip    a developer's per-user runtime dir (/run/user/1000)
/run/zip                the system default

The middle case is what makes a dev box work without configuration: /run/zip is not writable by a normal user and $XDG_RUNTIME_DIR is.

The environment is read on every call rather than cached, so a process that arranges its own runtime directory after start — and a test that does — sees the directory it actually has.

func Fits added in v1.31.1

func Fits(path string) error

Fits reports whether a path is short enough to bind, naming the overrun when it is not. The kernel's own answer is EINVAL, which arrives as "invalid argument" and mentions neither the length nor the path — so the first guess is always permissions, and the directory looks fine, and the real cause is a deep parent directory nobody thought to count.

func In

func In(dir, name string) string

In is the shape of every socket path, stated once: the plugin loader names a child's private socket with it too, so "a service's socket is <dir>/<name>.sock" has one definition.

func Path

func Path(name string) string

Path is the socket a service of this name is reached at.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL