Documentation
¶
Overview ¶
Package csvdb provides a generic CSV/TSV database adapter. Store implements both rowsync.Fetcher and rowsync.Updater over a file in an os.Root directory, with atomic writes and optional normalization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultGate = NewWriteGate()
DefaultGate is the shared write gate for the process.
Functions ¶
Types ¶
type Combined ¶
Init validates the root and file name. Combined fetches from several stores and concatenates their rows, e.g. clients.tsv + redirects.tsv, which share one row type and one target.
type Store ¶
type Store[T any] struct { Root *os.Root Name string Format string Gate *WriteGate Normalize func([]T) }
Store is a generic TSV/CSV file storage adapter backed by an os.Root. Root must be non-nil; Name is the file within the root directory.
func (*Store[T]) Update ¶
Update applies a plan to the file. It serializes Plan.Final, never raw source rows: UpdateMode plans keep destination-only rows, SyncMode plans drop them. A plan with no actions leaves the file untouched. Insert-only plans append without rewriting the existing snapshot; any update or delete takes the atomic replacement path. The previous file survives encoding or rename failures (temp file + rename, no fsync).
type WriteGate ¶
type WriteGate struct {
// contains filtered or unexported fields
}
WriteGate permits one local file write at a time.
func NewWriteGate ¶
func NewWriteGate() *WriteGate
NewWriteGate creates a gate that permits one write at a time.