Documentation
¶
Overview ¶
Package api is the sheet API's HTTP surface: one URL per document, the action selected by method × media type. The document plane (store, version, apply, notify) evaluates no expression; the compute plane — enabled when the operator turns it on — serves computed values in the SPECIFICATION §9 vendor types, making every served sheet an IMPORT*-able origin.
The read half of the HTTP surface: every representation a GET can serve — the change feed, a computed reference, a computed grid, or the source document — and the caching headers that keep them distinguishable.
Idempotency-Key replay: a retried batch returns its original result instead of re-applying or failing a now-stale precondition.
Replay over the change feed: what a reconnecting subscriber is owed from the journal, and what it is told when its resume point is gone.
A subscriber's session over the change feed, as the handler sees it: the replay it is owed on connect and the live events that follow.
Server-Sent Events framing: turning one journal event into one SSE frame, and forwarding a live subscription until it ends.
The write half of the HTTP surface: replacing or creating a document, applying an edits batch, deleting, and the preconditions every one of them requires.
Index ¶
Constants ¶
const ( TypeDoc = "application/vnd.tsvsheet.doc+tsv" TypeEdits = "application/vnd.tsvsheet.edits+tsv" TypeCells = "application/vnd.tsvsheet.cells+tsv" TypeSheet = "application/vnd.tsvsheet+tsv" TypeCell = "application/vnd.tsvsheet.cell+tsv" TypeRow = "application/vnd.tsvsheet.row+tsv" TypeColumn = "application/vnd.tsvsheet.column+tsv" TypeRange = "application/vnd.tsvsheet.range+tsv" TypeTSV = "text/tab-separated-values" TypeCSV = "text/csv" TypeStream = "text/event-stream" TypeProblem = "application/problem+json" )
The +tsv media-type family the API speaks. TypeDoc and TypeEdits are the document plane's own; the §9 vendor types (TypeSheet through TypeRange) mean computed values, in the shapes the language's IMPORT* builtins request — TestComputedRangeRowColumnShapes and TestGetValuesAcceptWithoutComputeIs406 assert the shapes and the source-versus-values refusal.
const ( SlugNotFound = problemNotFound SlugPrecondition = problemPrecondition SlugConflict = problemConflict SlugStaleBase = problemStaleBase SlugRefusedEdits = problemRefusedEdits SlugBadDocument = problemBadDocument SlugDocTooLarge = problemDocTooLarge SlugBadEdits = problemBadEdits )
The API's problem vocabulary. Each condition a client must be able to act on differently gets its own slug: a client port reconstructs the document plane's sentinels from these, so two conditions sharing a slug would make the remote adapter return a different error than the embedded one for the same cause. The exported names for the slugs a client acts on.
const ProblemBase = "https://tsvsheet.com/problems/"
ProblemBase prefixes every problem type URI (RFC 9457). It is exported because a client reads the type URI to tell one refusal from another.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock supplies the compute plane's evaluation time, injected so volatile functions are deterministic under test.
type ComputePlane ¶
type ComputePlane bool
ComputePlane selects whether the server carries the engine's compute plane.
const ( DocumentPlaneOnly ComputePlane = false WithComputePlane ComputePlane = true )
The two plane configurations, named at the call sites.
type Config ¶
type Config struct {
Port document.Port
Clock Clock
Limits tsvsheet.Limits
ComputeEnabled ComputePlane
}
Config assembles a handler.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the sheet API's http.Handler.
Pointer receivers are necessary: the handler owns the feed hub and the idempotency replay cache, which carry mutexes and shared maps.
func NewHandler ¶
NewHandler builds the API handler over its store.
type ProblemSlug ¶
type ProblemSlug = problemSlug
ProblemSlug names one error condition in a problem type URI. A client maps these back to the document plane's sentinels, so they are part of the wire contract rather than an implementation detail.