Documentation
¶
Overview ¶
Package machine encodes a model.Record as the stable JSON/NDJSON wire format described in docs/schema.md. The wire shapes here are a deliberately separate view-model from model.Record's Go-internal shapes (Field[T]'s generic {Value,Sources}, TimeValue's raw {Time,Raw,Parsed}) — this package owns the public API contract, and a breaking change to any shape below must bump SchemaVersion.
Index ¶
- Constants
- func Encode(w io.Writer, r model.Record, opts Options) error
- func EncodeASN(w io.Writer, r model.ASNRecord, opts Options) error
- func EncodeASNNDJSON(w io.Writer, r model.ASNRecord, opts Options) error
- func EncodeError(w io.Writer, domainName string, err error) error
- func EncodeIP(w io.Writer, r model.IPRecord, opts Options) error
- func EncodeIPNDJSON(w io.Writer, r model.IPRecord, opts Options) error
- func EncodeNDJSON(w io.Writer, r model.Record, opts Options) error
- type Options
Constants ¶
const SchemaVersion = 1
SchemaVersion is the current machine-output schema version.
Variables ¶
This section is empty.
Functions ¶
func EncodeASN ¶ added in v0.3.0
EncodeASN writes r as a single compact JSON object followed by a newline — the ASN-record counterpart to Encode.
func EncodeASNNDJSON ¶ added in v0.3.0
EncodeASNNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-target output, one record per line. Mechanically identical to EncodeASN; kept as a separate name so call sites make the multi-target intent explicit.
func EncodeError ¶
EncodeError writes a machine-mode error object to w: {"error": "...", "domain": "..."}. Used for stderr so stdout stays schema-clean even when a lookup fails in machine mode.
func EncodeIP ¶ added in v0.2.0
EncodeIP writes r as a single compact JSON object followed by a newline — the IP-record counterpart to Encode.
func EncodeIPNDJSON ¶ added in v0.2.0
EncodeIPNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-target output, one record per line. Mechanically identical to EncodeIP; kept as a separate name so call sites make the multi-target intent explicit.
func EncodeNDJSON ¶
EncodeNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-domain output, one record per line. Mechanically identical to Encode; kept as a separate name so call sites make the multi-domain intent explicit.