Help us shape the future of Go! Take the 2026 Go Developer Survey

wire

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package wire carries execution requests and results across a process boundary.

The envelope is a 4-byte big-endian length followed by a msgpack body. Framing rather than a bare value stream is what lets a parent tell a child that produced nothing (EOF before a header — it crashed) from one that produced a partial write (header then short body — corruption). Those are different failures and get different statuses.

Index

Constants

View Source
const MaxFrameBytes = 64 << 20

MaxFrameBytes caps a decoded frame. A payload larger than this is refused rather than allocated, so a corrupt or hostile length header cannot exhaust the reader's memory.

Variables

View Source
var ErrShortFrame = errors.New("short frame")

ErrShortFrame marks a frame whose declared length exceeded the bytes actually available. The writer died mid-write.

Functions

func Encode

func Encode(w io.Writer, f *Frame) error

Encode writes one length-prefixed frame.

Types

type Frame

type Frame struct {
	Kind    Kind          `msgpack:"kind"`
	Request *exec.Request `msgpack:"request,omitempty"`
	Result  *exec.Result  `msgpack:"result,omitempty"`
}

Frame is one message. Exactly one of Request or Result is set, matching Kind.

func Decode

func Decode(r io.Reader) (*Frame, error)

Decode reads one length-prefixed frame.

It returns io.EOF when the stream is empty, which means the writer produced nothing at all, and ErrShortFrame when a header was read but the body was incomplete.

type Kind

type Kind uint8

Kind identifies which side of the exchange a frame carries.

const (
	// KindRequest is a parent-to-child execution request.
	KindRequest Kind = 1
	// KindResult is a child-to-parent execution result.
	KindResult Kind = 2
)

Jump to

Keyboard shortcuts

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