Documentation
¶
Overview ¶
Package ipc implements peng's framed JSON-RPC transport for embedding hosts like peng-tui.
Frames are LSP-style: a sequence of `Header: Value\r\n` lines (only `Content-Length` is interpreted), an empty `\r\n`, then exactly Content-Length bytes of JSON payload. Multiple frames can flow in either direction over the same stream; each is self-delimited.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadFrame = errors.New("ipc: malformed frame")
ErrBadFrame is returned when the header section is malformed or Content-Length is missing/invalid.
Functions ¶
Types ¶
type FrameWriter ¶
type FrameWriter struct {
// contains filtered or unexported fields
}
FrameWriter serializes writes to an underlying io.Writer. Multiple goroutines (request responses, stream chunks, events) post frames concurrently; the writer's mutex serializes them so they don't interleave on the wire.
func NewFrameWriter ¶
func NewFrameWriter(w io.Writer) *FrameWriter
NewFrameWriter wraps w. Caller retains ownership of w; closing the writer is the caller's responsibility (typically the IPC server's shutdown path).
func (*FrameWriter) WriteFrame ¶
func (fw *FrameWriter) WriteFrame(body []byte) (int, error)
WriteFrame emits header + body as one frame. Returns the byte count written and any underlying writer error.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server runs the IPC dispatch loop against a server.Mux. One Server instance serves a single stdio pair (or any io.Reader/io.Writer combo — net.Pipe is used in tests).