sqlite

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlite is the durable store.Store: the res/graph store contract over one SQLite database, in pure Go (modernc.org/sqlite, no cgo).

The tables are created from the declarative layout of the contract (res/graph/testdata/store/v1/tables.json) when the database is new. There are no migrations: a database with another layout is refused. Short-lived commands and long-lived consumers share a database through SQLite's own locking; watches poll the durable change cursor.

Index

Constants

View Source
const PollInterval = 150 * time.Millisecond

PollInterval is how often a watch reads the durable cursor for commits made by other handles or processes. Commits through the same handle wake it at once.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, path string, options store.Options) (*Store, error)

Open opens or creates the store in the SQLite database at path. The file is created with mode 0600 and its directory with 0700.

func (*Store) Apply

func (s *Store) Apply(ctx context.Context, t store.Transaction) (store.Commit, error)

func (*Store) Changes

func (s *Store) Changes(ctx context.Context, ns string, after uint64, limit int) ([]store.Change, error)

Changes returns at most limit retained commits newer than after. Cursors are global to the store even when the result is filtered by namespace.

func (*Store) Close

func (s *Store) Close() error

Close ends every watch and closes the database. It is safe to call twice.

func (*Store) GetEdge

func (s *Store) GetEdge(ctx context.Context, ns, id string) (store.Edge, error)

func (*Store) GetVertex

func (s *Store) GetVertex(ctx context.Context, ns, id string) (store.Vertex, error)

func (*Store) QueryEdges

func (s *Store) QueryEdges(ctx context.Context, q store.EdgeQuery) ([]store.Edge, error)

func (*Store) QueryVertices

func (s *Store) QueryVertices(ctx context.Context, q store.VertexQuery) ([]store.Vertex, error)

func (*Store) Register

func (s *Store) Register(ctx context.Context, schema store.Schema) error

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, ns string) (store.Snapshot, error)

func (*Store) Traverse

func (s *Store) Traverse(ctx context.Context, ns, start string, maxDepth, maxVertices int) ([]store.Path, error)

func (*Store) Watch

func (s *Store) Watch(ctx context.Context, ns string, after uint64, buffer int) (<-chan store.Change, error)

Watch replays the retained changes after the cursor and then delivers later commits in cursor order. The channel closes when ctx ends, the store closes, the buffer fills or the cursor falls below the history floor; the consumer resumes from the last cursor it processed.

Jump to

Keyboard shortcuts

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