Documentation
¶
Overview ¶
Package store is the confined document store of the sheet API's document plane: .tsvt files under one operator-fixed root, read and replaced through os.Root so no path can escape, every write atomic (temp + rename), every mutation revision-checked, and every stored byte the engine's canonical serialization. The store never evaluates an expression — parsing for canonicalization and reference rewriting only.
Index ¶
- type Applied
- type DocPath
- type Expect
- type RootDir
- type Snapshot
- type Store
- func (s *Store) Apply(p DocPath, batch tsvsheet.Edits, expect tsvsheet.RevisionHex) (Applied, error)
- func (s *Store) Delete(p DocPath, expect tsvsheet.RevisionHex) error
- func (s *Store) Get(p DocPath) (Snapshot, error)
- func (s *Store) Put(p DocPath, body []byte, expect Expect) (Snapshot, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applied ¶
Applied is the result of an op-batch application: the state folded from and the state produced.
type DocPath ¶
type DocPath string
DocPath is a document's path relative to the store root. It must be clean, relative, and free of "!" (reserved by the HTTP binding's reference suffix).
type Expect ¶
type Expect struct {
// contains filtered or unexported fields
}
Expect is a mutation's precondition: a revision the document must currently have, or the requirement that it not exist.
func ExpectAbsent ¶
func ExpectAbsent() Expect
ExpectAbsent requires the document to not exist (create).
func ExpectRev ¶
func ExpectRev(rev tsvsheet.RevisionHex) Expect
ExpectRev requires the document to currently have revision rev.
type RootDir ¶
type RootDir string
RootDir is the operator-fixed directory a store confines itself to.
type Snapshot ¶
type Snapshot struct {
Doc tsvsheet.Document
Rev tsvsheet.RevisionHex
Text []byte
}
Snapshot is one document state: the parsed document, its canonical bytes, and their content address. Carrying the Document means no consumer ever reparses served text.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store serves and mutates the documents under one root directory.
Pointer receivers are necessary here: the store wraps an os.Root handle and a mutex serializing check-and-set mutations, neither of which may be copied.
func (*Store) Apply ¶
func (s *Store) Apply(p DocPath, batch tsvsheet.Edits, expect tsvsheet.RevisionHex) (Applied, error)
Apply folds the op batch over the document at p, which must currently have revision expect; the result is persisted atomically and both states returned. Any refusal — stale revision, in-band base conflict, refused op — leaves the file untouched.
func (*Store) Delete ¶
func (s *Store) Delete(p DocPath, expect tsvsheet.RevisionHex) error
Delete removes the document at p, which must currently have revision expect.