Documentation
¶
Overview ¶
Package ndjson provides shared NDJSON (newline-delimited JSON) framing utilities for both daemon IPC and adapter serve-mode communication.
Both the CLI-daemon Unix socket IPC and the daemon-adapter stdin/stdout IPC use NDJSON. This package ensures consistent buffer sizes (1MB max line), explicit Err() checking, and compact encoding across all IPC layers.
Index ¶
Constants ¶
const MaxLineBytes = 1 << 20 // 1MB
MaxLineBytes is the maximum size of a single NDJSON line (1MB). This matches the existing daemon IPC limit and prevents unbounded memory allocation from malformed or malicious input.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder wraps json.Encoder with compact encoding enforced (no indentation). Each Encode call writes exactly one JSON object followed by a newline.
func NewEncoder ¶
NewEncoder creates an Encoder that writes compact NDJSON to w.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner wraps bufio.Scanner with the correct buffer size for NDJSON lines. Always check Err() after Scan() returns false to distinguish EOF from errors.
func NewScanner ¶
NewScanner creates a Scanner that reads NDJSON lines from r with a 1MB buffer.
func (*Scanner) Bytes ¶
Bytes returns the current line as a byte slice. The slice is only valid until the next call to Scan.