Documentation
¶
Overview ¶
Package wire frames opaque payloads (JSON-RPC messages in practice) into Bison Relay private messages. Each PM carries exactly one part:
--mcp[v=1,sid=<hex>,mid=<hex>,seq=<n>/<total>,exp=<unix>]--<base64 chunk>
A part with seq=1/1 is a complete message. Bison Relay delivers PMs as discrete, ordered, acknowledged units, so the envelope only has to distinguish MCP traffic from human chat on the same DM thread, group the chunks of oversized payloads, and carry a deadline: relay delivery is store-and-forward, so a request can arrive long after the caller stopped waiting and must be droppable.
Index ¶
Constants ¶
const DefaultChunkSize = 200 * 1024
DefaultChunkSize is the raw payload bytes per part before base64. Base64 expands 4/3, so parts stay far below Bison Relay's 1 MiB routed-message floor with room for the tag and JSON framing.
const MaxParts = 64
MaxParts bounds a single message's chunk count. 64 parts at the default chunk size is ~12.8 MiB raw, beyond any payload the transport should carry.
const Version = 1
Version is the envelope version emitted by Encode and accepted by Parse.
Variables ¶
Functions ¶
Types ¶
type Assembler ¶
type Assembler struct {
// contains filtered or unexported fields
}
Assembler reassembles chunked messages with hard bounds so a hostile peer cannot grow the buffers without limit.
func NewAssembler ¶
func NewAssembler(cfg AssemblerConfig) *Assembler
type AssemblerConfig ¶
type AssemblerConfig struct {
// MaxPendingPerPeer caps concurrently reassembling messages per peer.
MaxPendingPerPeer int
// MaxMessageBytes caps one reassembled message.
MaxMessageBytes int64
// MaxTotalBytes caps all buffered chunks across peers.
MaxTotalBytes int64
// Timeout evicts partial messages that stopped arriving.
Timeout time.Duration
}
AssemblerConfig bounds a peer's in-flight reassembly state. The zero value selects the defaults.
type Part ¶
type Part struct {
SID string
MID string
Seq int
Total int
// Exp is the sender-set deadline in unix seconds; 0 means none.
Exp int64
Chunk []byte
}
Part is one parsed envelope.