Documentation
¶
Overview ¶
Package storage holds the in-memory reference implementation of the durable Storage contract.
Index ¶
- type MemoryStorage
- func (storage *MemoryStorage) Close(_ context.Context) error
- func (storage *MemoryStorage) Commit(_ context.Context, batches [][]durable.StorageWrite, ...) (durable.CommitResult, error)
- func (storage *MemoryStorage) Conversation(_ context.Context, id durable.ConversationId) (*durable.ConversationRecord, error)
- func (storage *MemoryStorage) Document(_ context.Context, id durable.DocumentId, at durable.DocumentPoint) (*durable.StoredDocument, error)
- func (storage *MemoryStorage) Entry(_ context.Context, id durable.EntryId) (*durable.EntryAt, error)
- func (storage *MemoryStorage) FindDocument(_ context.Context, address durable.DocumentAddress, at durable.DocumentPoint) (*durable.DocumentRecord, error)
- func (storage *MemoryStorage) FindLatestHeadMarker(_ context.Context, conversationId durable.ConversationId, ...) (*durable.EntryRecord, error)
- func (storage *MemoryStorage) MintId() (int64, error)
- func (storage *MemoryStorage) PrepareCommit(writes []durable.StorageWrite) (*PreparedMemoryCommit, error)
- func (storage *MemoryStorage) PrepareCommitAt(writes []durable.StorageWrite, seq durable.Seq) (*PreparedMemoryCommit, error)
- func (storage *MemoryStorage) Reopen()
- func (storage *MemoryStorage) ScanConversations(_ context.Context, query durable.ConversationQuery, limit int, ...) (durable.Page[durable.ConversationRecord, durable.Cursor], error)
- func (storage *MemoryStorage) ScanDocuments(_ context.Context, query durable.DocumentQuery, limit int, ...) (durable.Page[durable.DocumentRecord, durable.Cursor], error)
- func (storage *MemoryStorage) ScanEntries(_ context.Context, query durable.EntryQuery, limit int, cursor durable.Cursor) (durable.Page[durable.EntryRecord, durable.Cursor], error)
- func (storage *MemoryStorage) ScanSubmissions(_ context.Context, query durable.SubmissionQuery, limit int, ...) (durable.Page[durable.SubmissionRecord, durable.Cursor], error)
- func (storage *MemoryStorage) ScanTasks(_ context.Context, query durable.TaskQuery, limit int, cursor durable.Cursor) (durable.Page[storedTask, durable.Cursor], error)
- func (storage *MemoryStorage) Submission(_ context.Context, id durable.SubmissionId) (*durable.SubmissionRecord, error)
- func (storage *MemoryStorage) SubmissionByRequest(_ context.Context, conversationId durable.ConversationId, requestId string) (*durable.SubmissionRecord, error)
- func (storage *MemoryStorage) Task(_ context.Context, id durable.TaskId) (*storedTask, error)
- func (storage *MemoryStorage) VisibleEntry(_ context.Context, conversationId durable.ConversationId, id durable.EntryId) (*durable.EntryAt, error)
- type PreparedMemoryCommit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MemoryStorage ¶
type MemoryStorage struct {
// contains filtered or unexported fields
}
MemoryStorage is the detached in-memory reference implementation of durable.Storage.
Reads and retained writes are copied intentionally to match the ownership boundary of serialization-backed stores. This is backend conformance, not validation. It is safe for concurrent use; the owning Session serializes commits.
func NewMemoryStorage ¶
func NewMemoryStorage() *MemoryStorage
NewMemoryStorage returns empty storage.
func (*MemoryStorage) Close ¶
func (storage *MemoryStorage) Close(_ context.Context) error
Close releases the storage; all later operations fail.
func (*MemoryStorage) Commit ¶
func (storage *MemoryStorage) Commit( _ context.Context, batches [][]durable.StorageWrite, receive func(index int, seq durable.Seq), ) (durable.CommitResult, error)
Commit applies batches one by one, each checked against the state the earlier ones left (prepareCommitLocked only checks and detaches, so a batch it refuses changed nothing); it stops at the first one refused. Memory is durable at once; the receipts follow the last batch, under the storage lock as the old adoption was, so a read never sees a batch before its adoption.
func (*MemoryStorage) Conversation ¶
func (storage *MemoryStorage) Conversation( _ context.Context, id durable.ConversationId, ) (*durable.ConversationRecord, error)
Conversation looks up one conversation by exact ID.
func (*MemoryStorage) Document ¶
func (storage *MemoryStorage) Document( _ context.Context, id durable.DocumentId, at durable.DocumentPoint, ) (*durable.StoredDocument, error)
Document materializes one specific incarnation by ID at the selected point without following a replacement at its address.
func (*MemoryStorage) Entry ¶
func (storage *MemoryStorage) Entry(_ context.Context, id durable.EntryId) (*durable.EntryAt, error)
Entry looks up one global entry and the sequence of the commit that persisted it.
func (*MemoryStorage) FindDocument ¶
func (storage *MemoryStorage) FindDocument( _ context.Context, address durable.DocumentAddress, at durable.DocumentPoint, ) (*durable.DocumentRecord, error)
FindDocument resolves the incarnation occupying one exact logical address at the selected point.
func (*MemoryStorage) FindLatestHeadMarker ¶
func (storage *MemoryStorage) FindLatestHeadMarker( _ context.Context, conversationId durable.ConversationId, atOrBeforeEntryId *durable.EntryId, ) (*durable.EntryRecord, error)
FindLatestHeadMarker returns the newest visible entry with a head at or below the optional inclusive cutoff.
func (*MemoryStorage) MintId ¶
func (storage *MemoryStorage) MintId() (int64, error)
MintId returns a fresh candidate from the Session-global numeric ID namespace.
func (*MemoryStorage) PrepareCommit ¶
func (storage *MemoryStorage) PrepareCommit(writes []durable.StorageWrite) (*PreparedMemoryCommit, error)
PrepareCommit validates and detaches one commit at the next sequence without changing observable state.
func (*MemoryStorage) PrepareCommitAt ¶
func (storage *MemoryStorage) PrepareCommitAt( writes []durable.StorageWrite, seq durable.Seq, ) (*PreparedMemoryCommit, error)
PrepareCommitAt validates and detaches one commit at seq, which must not be below the next sequence.
func (*MemoryStorage) Reopen ¶
func (storage *MemoryStorage) Reopen()
Reopen undoes Close, keeping every committed record, as a fresh process reopening the same database would. Tests use it to read what a failed Session left (upstream's session-support ControlledStorage.reopen).
func (*MemoryStorage) ScanConversations ¶
func (storage *MemoryStorage) ScanConversations( _ context.Context, query durable.ConversationQuery, limit int, cursor durable.Cursor, ) (durable.Page[durable.ConversationRecord, durable.Cursor], error)
ScanConversations scans conversations by ID in query.Order, ascending by default.
func (*MemoryStorage) ScanDocuments ¶
func (storage *MemoryStorage) ScanDocuments( _ context.Context, query durable.DocumentQuery, limit int, cursor durable.Cursor, ) (durable.Page[durable.DocumentRecord, durable.Cursor], error)
ScanDocuments scans incarnations alive in one exact scope at the selected point.
func (*MemoryStorage) ScanEntries ¶
func (storage *MemoryStorage) ScanEntries( _ context.Context, query durable.EntryQuery, limit int, cursor durable.Cursor, ) (durable.Page[durable.EntryRecord, durable.Cursor], error)
ScanEntries scans the inclusive visible range in query.Order (descending by default), returning at most limit entries.
func (*MemoryStorage) ScanSubmissions ¶
func (storage *MemoryStorage) ScanSubmissions( _ context.Context, query durable.SubmissionQuery, limit int, cursor durable.Cursor, ) (durable.Page[durable.SubmissionRecord, durable.Cursor], error)
ScanSubmissions scans submissions matching every supplied filter by ID in query.Order, ascending by default.
func (*MemoryStorage) ScanTasks ¶
func (storage *MemoryStorage) ScanTasks( _ context.Context, query durable.TaskQuery, limit int, cursor durable.Cursor, ) (durable.Page[storedTask, durable.Cursor], error)
ScanTasks scans task records matching every supplied filter by ID in query.Order, ascending by default.
func (*MemoryStorage) Submission ¶
func (storage *MemoryStorage) Submission( _ context.Context, id durable.SubmissionId, ) (*durable.SubmissionRecord, error)
Submission looks up the latest complete record for one admitted submission.
func (*MemoryStorage) SubmissionByRequest ¶
func (storage *MemoryStorage) SubmissionByRequest( _ context.Context, conversationId durable.ConversationId, requestId string, ) (*durable.SubmissionRecord, error)
SubmissionByRequest finds a submission by its conversation-scoped host deduplication key.
func (*MemoryStorage) VisibleEntry ¶
func (storage *MemoryStorage) VisibleEntry( _ context.Context, conversationId durable.ConversationId, id durable.EntryId, ) (*durable.EntryAt, error)
VisibleEntry looks up one entry only when it is visible through the requested conversation's ancestry.
type PreparedMemoryCommit ¶
type PreparedMemoryCommit struct {
// contains filtered or unexported fields
}
PreparedMemoryCommit is a fully validated, detached state mutation whose application performs no fallible preparation.
func (*PreparedMemoryCommit) Apply ¶
func (prepared *PreparedMemoryCommit) Apply() durable.Seq
Apply applies the mutation once and returns its sequence; later calls return the same sequence.
func (*PreparedMemoryCommit) Seq ¶
func (prepared *PreparedMemoryCommit) Seq() durable.Seq
Seq returns the commit sequence the mutation applies at.
func (*PreparedMemoryCommit) Writes ¶
func (prepared *PreparedMemoryCommit) Writes() []durable.StorageWrite
Writes returns a detached copy of the resolved writes, for persistence. Mutating it never changes storage state.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
ops
Package ops replays stored Chord operation batches for the storage backends.
|
Package ops replays stored Chord operation batches for the storage backends. |
|
scan
Package scan resolves the order and position of a built-in storage scan.
|
Package scan resolves the order and position of a built-in storage scan. |
|
serial
Package serial is the one operation queue of the SQLite database adapters: operations run in call order and a transaction holds the queue until it settles (Pi's SerialQueue and the promise chain of NodeSqliteDatabase).
|
Package serial is the one operation queue of the SQLite database adapters: operations run in call order and a transaction holds the queue until it settles (Pi's SerialQueue and the promise chain of NodeSqliteDatabase). |
|
writes
Package writes normalizes durable storage writes for the storage backends.
|
Package writes normalizes durable storage writes for the storage backends. |
|
Package jsonl is the portable JSONL implementation of the durable Storage contract: one main commit log and per-document and per-task sidecar logs in one directory, accessed through a file system capability.
|
Package jsonl is the portable JSONL implementation of the durable Storage contract: one main commit log and per-document and per-task sidecar logs in one directory, accessed through a file system capability. |
|
node
Package node opens JSONL durable storage on the local file system, the Go counterpart of Pi's Node JSONL adapter.
|
Package node opens JSONL durable storage on the local file system, the Go counterpart of Pi's Node JSONL adapter. |
|
Package sqlite is the portable SQLite storage core of pi-durable: the durable schema, its migrations, and SqliteStorage.
|
Package sqlite is the portable SQLite storage core of pi-durable: the durable schema, its migrations, and SqliteStorage. |
|
cloudflare
Package cloudflare opens durable storage on the SQLite storage of a Cloudflare Durable Object.
|
Package cloudflare opens durable storage on the SQLite storage of a Cloudflare Durable Object. |
|
node
Package node opens durable storage on a native SQLite connection.
|
Package node opens durable storage on a native SQLite connection. |
|
Package store is Durable's Storage on Chord's store: StoreStorage keeps Durable's records as declared tables of the store, its documents in the store's documents engine, and commits as one series of the store's commit queue.
|
Package store is Durable's Storage on Chord's store: StoreStorage keeps Durable's records as declared tables of the store, its documents in the store's documents engine, and commits as one series of the store's commit queue. |