extsocket

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package extsocket is the private Unix socket the CLI listens on before an extension starts. The extension reports telemetry to it, and the CLI reads one bounded JSON payload from it after the extension exits.

On Unix the socket sits in a directory only the current user can open. On Windows the directory is in the per-user temporary directory. The package never logs or prints the socket path or the payload.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPathTooLong means the socket path would not fit a Unix socket address.
	ErrPathTooLong = errors.New("socket path is too long")
	// ErrNoConnection means no client connected before the deadline.
	ErrNoConnection = errors.New("no connection to the telemetry socket")
	// ErrNoPayload means a client connected and closed without sending data.
	ErrNoPayload = errors.New("telemetry connection sent no data")
	// ErrUnreadable means the connection failed, timed out, or did not carry
	// a single well-formed JSON object no longer than maxPayload.
	ErrUnreadable = errors.New("telemetry payload is unreadable")
)

Functions

This section is empty.

Types

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener is a listening socket in a private directory.

func Listen

func Listen() (*Listener, error)

Listen removes stale directories left by crashed runs, creates a private directory and listens on a socket in it. Close the Listener to remove the directory.

func (*Listener) Close

func (l *Listener) Close() error

Close closes the listener and removes the directory. It is safe to call twice.

func (*Listener) Collect

func (l *Listener) Collect(ctx context.Context) (Payload, error)

Collect accepts the first connection and reads one payload from it. One deadline covers the accept and the read together, and ctx can only shorten it. Call it after the extension exits: the kernel has queued the connection by then, so the accept waits at most acceptWait.

Errors are ErrNoConnection, ErrNoPayload or ErrUnreadable, and never carry any of the payload.

func (*Listener) Path

func (l *Listener) Path() string

Path returns the socket path.

type Payload

type Payload struct {
	// Version is the payload version, or 0 when the payload had none.
	Version int
	// Attributes holds the raw JSON value of each attribute, or nil when the
	// payload had no attributes key.
	Attributes map[string]json.RawMessage
}

Payload is what an extension sent. The package judges nothing about the version or the attributes: the caller does.

Jump to

Keyboard shortcuts

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