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
- type Store
- func (s *Store) Apply(ctx context.Context, t store.Transaction) (store.Commit, error)
- func (s *Store) Changes(ctx context.Context, ns string, after uint64, limit int) ([]store.Change, error)
- func (s *Store) Close() error
- func (s *Store) GetEdge(ctx context.Context, ns, id string) (store.Edge, error)
- func (s *Store) GetVertex(ctx context.Context, ns, id string) (store.Vertex, error)
- func (s *Store) QueryEdges(ctx context.Context, q store.EdgeQuery) ([]store.Edge, error)
- func (s *Store) QueryVertices(ctx context.Context, q store.VertexQuery) ([]store.Vertex, error)
- func (s *Store) Register(ctx context.Context, schema store.Schema) error
- func (s *Store) Snapshot(ctx context.Context, ns string) (store.Snapshot, error)
- func (s *Store) Traverse(ctx context.Context, ns, start string, maxDepth, maxVertices int) ([]store.Path, error)
- func (s *Store) Watch(ctx context.Context, ns string, after uint64, buffer int) (<-chan store.Change, error)
Constants ¶
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 ¶
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) 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) QueryEdges ¶
func (*Store) QueryVertices ¶
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.