Documentation
¶
Overview ¶
The store's own failures — the mechanical ones a filesystem can produce. The document plane's contract errors (missing, precondition, exists, path, syntax) belong to the document package, because a client port must be able to return the same ones.
The filesystem mechanics behind the embedded port: reading and parsing a stored document, checking a write's precondition, and landing bytes atomically inside the confined root.
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 ¶
- Constants
- type Applied
- type Created
- type DocPath
- type Expect
- type RootDir
- type Snapshot
- type Store
- func (s *Store) Apply(_ context.Context, p DocPath, batch tsvsheet.Edits, ...) (Applied, error)
- func (s *Store) Delete(_ context.Context, p DocPath, expect tsvsheet.RevisionHex) error
- func (s *Store) Get(_ context.Context, p DocPath) (Snapshot, error)
- func (s *Store) Put(_ context.Context, p DocPath, body []byte, expect Expect) (Snapshot, Created, error)
Constants ¶
const ( // ErrParse is a stored document that no longer parses — corruption or an // out-of-band edit, never something a request did. ErrParse errs.Const = "stored document does not parse" // ErrRead is a document that exists but could not be read. ErrRead errs.Const = "failed to read document" // ErrRootOpen is a document root that cannot be opened for confinement. ErrRootOpen errs.Const = "document root cannot be opened" // ErrWrite is a write that did not land; the previous document survives. ErrWrite errs.Const = "failed to write document" )
Keep these constants sorted alphabetically.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Applied ¶
The document vocabulary this store speaks; the contract lives in the document package so a caller matches one set of types and errors whether it holds this embedded store or a client over HTTP.
type Created ¶
The document vocabulary this store speaks; the contract lives in the document package so a caller matches one set of types and errors whether it holds this embedded store or a client over HTTP.
type DocPath ¶
The document vocabulary this store speaks; the contract lives in the document package so a caller matches one set of types and errors whether it holds this embedded store or a client over HTTP.
type Expect ¶
The document vocabulary this store speaks; the contract lives in the document package so a caller matches one set of types and errors whether it holds this embedded store or a client over HTTP.
type RootDir ¶
type RootDir string
RootDir is the operator-fixed directory a store confines itself to.
type Snapshot ¶
The document vocabulary this store speaks; the contract lives in the document package so a caller matches one set of types and errors whether it holds this embedded store or a client over HTTP.
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( _ context.Context, 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.