wire

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 8 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 wire carries the sync endpoint protocol over one exec stream: length- prefixed protobuf frames, request/response, one request in flight.

One request in flight governs requests, not frames. A request that carries a body is followed by chunk frames terminated by an eof chunk, which is what lets content stream rather than be buffered whole — the endpoint shares the container's cgroup and cannot afford to hold a file in memory.

Index

Constants

View Source
const (
	// ChunkSize is the body chunk. Matches the file upload chunk the CLI
	// already uses.
	ChunkSize = 64 << 10

	// MaxFrameSize bounds a single frame. Bodies are chunked, so the only
	// frames near this are scan responses on very wide trees.
	MaxFrameSize = 16 << 20
)

Variables

View Source
var ErrBodyTooLarge = errors.New("body exceeds declared size")

ErrBodyTooLarge reports a body that exceeded the size its request declared. The endpoint stops reading rather than filling the workspace volume.

Functions

This section is empty.

Types

type Conn

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

Conn is one end of the protocol. Reads are single-threaded by the request/response discipline; writes take a mutex because a body is written as many frames and must not interleave with anything else.

func NewConn

func NewConn(r io.Reader, w io.Writer) *Conn

func (*Conn) DiscardBody

func (c *Conn) DiscardBody() error

DiscardBody drains a body the caller has decided not to keep. The stream is a single pipe with no way to cancel, so an unwanted body must still be read to its end before the next request can be sent.

func (*Conn) ReadBody

func (c *Conn) ReadBody(dst io.Writer, limit int64) error

ReadBody consumes chunk frames into dst until the eof chunk. A frame that is not a chunk is a protocol violation: the peer cannot start something else while a body is in flight.

func (*Conn) ReadFrame

func (c *Conn) ReadFrame() (*syncv1.Frame, error)

func (*Conn) WriteBody

func (c *Conn) WriteBody(src io.Reader, limit int64) error

WriteBody streams src as chunk frames and terminates with an eof chunk. It stops at limit bytes so a source that grew since it was declared cannot run unbounded; pass a negative limit for no bound.

func (*Conn) WriteFrame

func (c *Conn) WriteFrame(frame *syncv1.Frame) error

func (*Conn) WriteRequest

func (c *Conn) WriteRequest(request *syncv1.Request) error

func (*Conn) WriteResponse

func (c *Conn) WriteResponse(response *syncv1.Response) error

Jump to

Keyboard shortcuts

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