Documentation
¶
Overview ¶
Package prefixstore partitions one storage adapter between several servers by giving each its own prefix of the workspace-id space.
A storage adapter has one flat space of workspaces and no notion of who groups them. A host that serves several applications from one database needs exactly one thing of it — that no application can read or write another's workspaces — and a prefix delivers it: the host hands each application a wrapped adapter, that application's servers go on using their own bare workspace ids, and every id reaching the database carries the prefix.
store := sqlitestore.Open(path) srv, err := server.New(prefixstore.Wrap(store, "acme/"))
The prefix must be one no workspace id can begin with, or two applications share a partition. A trailing separator outside the id alphabet is what guarantees that; the engine's Manager uses "<appID>/", and `/` is not a legal workspace-id character.
What the prefix reaches ¶
Every workspace id crossing the seam, in both directions: the ids passed to the transaction methods, the Range each work query scans, and the ids those queries return, which come back stripped. The optional capabilities keyed by workspace — leases, cursor state, replica reads — are wrapped the same way, so background passes and pull cursors are partitioned with the data.
The server-global catalog is NOT reachable through a wrapped adapter. It belongs to no workspace and therefore to no partition; a host that keeps state there uses the adapter it wrapped.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
Wrap returns a view of inner in which every workspace id is prefixed, so that servers built on it cannot see workspaces outside the prefix. An empty prefix returns inner unchanged.
Close on the returned adapter is a no-op: inner keeps its handle, and the caller that opened it closes it.
The view is not a storage.As chain. A capability it does not know how to prefix stays invisible rather than resolving to an unpartitioned one, so storage.As answers false for anything added after this package rather than handing out a view that reaches every partition.
Types ¶
This section is empty.