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) NextRawRecord ¶ added in v0.3.0
NextRawRecord returns the raw JSON bytes for the next issue record in the stream without decoding them into a typed struct. This method is intended for callers that need to decode older backup versions whose record schema differs from the current domain.BackupIssueRecord (for example, restoring a v2 backup that carries the now-removed idempotency_key field).
When no more records are available it returns nil, false, nil. On parse error it returns nil, false, and a non-nil error.
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) 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.