sessiontest

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sessiontest provides an in-memory session.Store that keeps all committed state, as pi-durable's MemoryStorage does. It is the reference store of the Session layer's tests: every read is answered, none returns session.NeedRead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Elapsed

func Elapsed(p hopcost.Profile) func(session.Ended) (callback, work int)

Elapsed is the Loop.Elapsed of a Session over a store of the given profile whose reads the Session's own transaction charges cover: Pi's ticks from a line job's start to the return of its work (hopcost.Job.Return, hopcost.ReadReturn).

func MemoryStoreTicks

func MemoryStoreTicks([][]session.Write) (read, receive, resume int)

MemoryStoreTicks is the Loop.StoreTicks of MemoryStorage: it reads its ID counter and stores in the tick of the call, and the writer resumes hopcost.MemoryCommitResume ticks after it (`await storage.commit(...)` through the Session's guard).

Types

type Committed

type Committed struct {
	Seq    session.Seq
	Writes []session.Write
}

Committed is one applied commit.

type MemStore

type MemStore struct {

	// Commits records every committed write batch, for tests that compare
	// the write stream.
	Commits []Committed
	// contains filtered or unexported fields
}

MemStore is an in-memory session.Store.

func New

func New() *MemStore

New returns an empty store: the next ID is 2 (1 is the root conversation) and the next sequence 1.

func (*MemStore) Commit

func (m *MemStore) Commit(writes []session.Write, nextID session.ID) (session.Seq, error)

Commit implements session.Store.

func (*MemStore) Conversation

func (m *MemStore) Conversation(id session.ID) (*jv.Object, error)

Conversation implements session.Store.

func (*MemStore) Document

func (m *MemStore) Document(id session.ID, at session.Point) (*session.StoredDoc, error)

Document implements session.Store.

func (*MemStore) Entry

func (m *MemStore) Entry(id session.ID) (*jv.Object, session.Seq, error)

Entry implements session.Store.

func (*MemStore) EntryIn

func (m *MemStore) EntryIn(conv, id session.ID) (*jv.Object, session.Seq, error)

EntryIn implements session.Store.

func (*MemStore) FindDocument

func (m *MemStore) FindDocument(a session.Address, at session.Point) (*jv.Object, error)

FindDocument implements session.Store.

func (*MemStore) LatestHeadMarker

func (m *MemStore) LatestHeadMarker(conv, atOrBefore session.ID) (*jv.Object, error)

LatestHeadMarker implements session.Store.

func (*MemStore) NextID

func (m *MemStore) NextID() session.ID

NextID is the next unminted ID the store has seen.

func (*MemStore) NextSeq

func (m *MemStore) NextSeq() session.Seq

NextSeq is the sequence the next commit takes.

func (*MemStore) ScanConversations

func (m *MemStore) ScanConversations(q session.ConversationQuery, limit int, after session.ID) (session.Page, error)

ScanConversations implements session.Store.

func (*MemStore) ScanDocuments

func (m *MemStore) ScanDocuments(scope session.Scope, at session.Point, kind string, limit int, after session.ID) (session.Page, error)

ScanDocuments implements session.Store.

func (*MemStore) ScanEntries

func (m *MemStore) ScanEntries(q session.EntryQuery, limit int, after session.ID) (session.Page, error)

ScanEntries implements session.Store.

func (*MemStore) ScanSubmissions

func (m *MemStore) ScanSubmissions(q session.SubmissionQuery, limit int, after session.ID) (session.Page, error)

ScanSubmissions implements session.Store.

func (*MemStore) ScanTasks

func (m *MemStore) ScanTasks(q session.TaskQuery, limit int, after session.ID) (session.Page, error)

ScanTasks implements session.Store.

func (*MemStore) Submission

func (m *MemStore) Submission(id session.ID) (*jv.Object, error)

Submission implements session.Store.

func (*MemStore) SubmissionByRequest

func (m *MemStore) SubmissionByRequest(conv session.ID, request string) (*jv.Object, error)

SubmissionByRequest implements session.Store.

func (*MemStore) Task

func (m *MemStore) Task(id session.ID) (*jv.Object, error)

Task implements session.Store.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL