jsonl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package jsonl implements the backup driven-port interfaces using the JSON Lines format. Each line in the output file is a self-contained JSON object: the first line is the backup header (metadata), and every subsequent line is an issue record.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader reads backup data from a JSON Lines stream. The first line is expected to be a domain.BackupHeader; all subsequent lines are domain.BackupIssueRecord values. The caller must call Close when finished.

func NewReader

func NewReader(r io.ReadCloser) *Reader

NewReader creates a Reader that reads JSONL from r. Close delegates to r's Close method when reading is complete.

func (*Reader) Close

func (r *Reader) Close() error

Close releases resources held by the reader.

func (*Reader) NextRecord

func (r *Reader) NextRecord() (domain.BackupIssueRecord, bool, error)

NextRecord returns the next issue record from the backup stream. When no more records are available, it returns a zero IssueRecord, false, and a nil error. If a parse error occurs, the error is non-nil and iteration should stop.

func (*Reader) ReadHeader

func (r *Reader) ReadHeader() (domain.BackupHeader, error)

ReadHeader reads the first JSONL line as the backup metadata header. Must be called exactly once before any NextRecord calls.

type Writer

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

Writer writes backup data in JSON Lines format. Each call to WriteHeader or WriteRecord produces exactly one line of JSON followed by a newline character. The caller must call Close when finished to flush any buffered data.

func NewWriter

func NewWriter(w io.WriteCloser) *Writer

NewWriter creates a Writer that writes JSONL to w. Close delegates to w's Close method after all writes are complete.

func (*Writer) Close

func (w *Writer) Close() error

Close flushes any buffered output and closes the underlying writer.

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(header domain.BackupHeader) error

WriteHeader writes the backup metadata header as the first JSONL line. Must be called exactly once before any WriteRecord calls.

func (*Writer) WriteRecord

func (w *Writer) WriteRecord(record domain.BackupIssueRecord) error

WriteRecord writes a single issue record as one JSONL line.

Jump to

Keyboard shortcuts

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