protocol

package
v1.46.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressedFlag byte = 0x01 // Message is compressed
	EndStreamFlag  byte = 0x02 // Final message in stream
)

Envelope protocol flags

Variables

This section is empty.

Functions

func CompressEnvelopeIfLarge added in v1.44.0

func CompressEnvelopeIfLarge(payload []byte, threshold int) (compressed []byte, wasCompressed bool, err error)

CompressEnvelopeIfLarge gzip-compresses payload when it exceeds threshold bytes, returning the compressed bytes and wasCompressed=true. Payloads at or under the threshold are returned unmodified with wasCompressed=false so callers can decide whether to set the envelope's CompressedFlag (see CompressedFlag, above) before writing the frame.

server/services/connectrpc_websocket.go's writeCurrentPaneResponse is the shared envelope-writing helper that calls this; all CurrentPaneRequest response paths route through it so compression is applied uniformly.

func CreateEnvelope

func CreateEnvelope(flags byte, data []byte) []byte

CreateEnvelope creates an envelope with the given flags and data.

func WriteEnvelope

func WriteEnvelope(w io.Writer, flags byte, data []byte) error

WriteEnvelope writes an envelope to an io.Writer.

Types

type Envelope

type Envelope struct {
	Flags  byte
	Length uint32
	Data   []byte
}

Envelope represents a ConnectRPC envelope message with flags and data. Format: [1 byte flags][4 bytes length][N bytes data]

func ParseEnvelope

func ParseEnvelope(data []byte) (*Envelope, []byte, error)

ParseEnvelope reads an envelope from the provided data. Returns the parsed envelope and any remaining unconsumed data.

func ReadEnvelope

func ReadEnvelope(r io.Reader) (*Envelope, error)

ReadEnvelope reads a single envelope from an io.Reader.

func (*Envelope) IsCompressed

func (e *Envelope) IsCompressed() bool

IsCompressed checks if the envelope has the Compressed flag set.

func (*Envelope) IsEndStream

func (e *Envelope) IsEndStream() bool

IsEndStream checks if the envelope has the EndStream flag set.

Jump to

Keyboard shortcuts

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