wire

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AckGrainBytes    = 16 << 10
	AckHighWatermark = 256 << 10
	AckLowWatermark  = 64 << 10
	AckPendingLimit  = 1 << 20
	DropQueueLimit   = 64 << 10
)
View Source
const (
	Subprotocol                = "compozy.terminal.v3"
	ProtocolDescription        = "" /* 410-byte string literal not displayed */
	MaxInputBytes              = 65536
	MinCols                    = 20
	MaxCols                    = 2000
	MinRows                    = 5
	MaxRows                    = 1000
	ServerOpOutput        byte = 0x01
	ServerOpAttached      byte = 0x02
	ServerOpExit          byte = 0x03
	ServerOpError         byte = 0x04
	ServerOpTitle         byte = 0x05
	ServerOpResized       byte = 0x06
	ServerOpGap           byte = 0x07
	ServerOpPresence      byte = 0x08
	ServerOpRedactedInput byte = 0x09
	ClientOpInput         byte = 0x01
	ClientOpAck           byte = 0x02
	ClientOpResize        byte = 0x03
	ClientOpSignal        byte = 0x04
	ClientOpDetach        byte = 0x05
)

Variables

View Source
var (
	ErrUnknownOpcode = errors.New("terminal wire: unknown opcode")
	ErrInvalidFrame  = errors.New("terminal wire: invalid frame")
	ErrInputTooLarge = errors.New("terminal wire: input frame exceeds 64 KiB")
)
View Source
var ProtocolManifest []byte

ProtocolManifest is the authoritative terminal wire manifest embedded for code generation.

Functions

func AckBytes

func AckBytes(frame Frame) (uint32, error)

func ClampDimensions

func ClampDimensions(cols, rows uint16) (uint16, uint16, bool)

ClampDimensions normalizes a non-zero terminal size to protocol bounds.

func EncodeClient

func EncodeClient(frame Frame) ([]byte, error)

func EncodeServer

func EncodeServer(frame Frame) ([]byte, error)

func ValidOpcode

func ValidOpcode(direction Direction, opcode byte) bool

ValidOpcode reports whether opcode is assigned in the selected direction.

Types

type Direction

type Direction uint8

Direction selects the opcode namespace used to validate a frame.

const (
	ServerToClient Direction = iota + 1
	ClientToServer
)

type Flow

type Flow string
const (
	FlowAck  Flow = "ack"
	FlowDrop Flow = "drop"
)

type Frame

type Frame struct {
	Op      byte
	Seq     uint64
	Payload []byte
}

func DecodeClient

func DecodeClient(encoded []byte) (Frame, error)

func DecodeServer

func DecodeServer(encoded []byte) (Frame, error)

func NewACK

func NewACK(bytes uint32) Frame

type Queue

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

func NewQueue

func NewQueue(options QueueOptions) *Queue

func (*Queue) Ack

func (q *Queue) Ack(bytes int)

func (*Queue) Close

func (q *Queue) Close()

func (*Queue) CloseReason

func (q *Queue) CloseReason() string

func (*Queue) Enqueue

func (q *Queue) Enqueue(frame Frame, end uint64)

func (*Queue) Finish

func (q *Queue) Finish()

func (*Queue) Flow

func (q *Queue) Flow() Flow

func (*Queue) Frames

func (q *Queue) Frames() <-chan Frame

func (*Queue) PendingBytes

func (q *Queue) PendingBytes() int

type QueueOptions

type QueueOptions struct {
	Flow        Flow
	Now         func() time.Time
	SlowTimeout time.Duration
	Demoted     func(reason string)
	Evicted     func(reason string)
}

Jump to

Keyboard shortcuts

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