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 ¶
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 ¶
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 ¶
Close closes the listener and removes the directory. It is safe to call twice.
func (*Listener) Collect ¶
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.
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.