Help us shape the future of Go! Take the 2026 Go Developer Survey

store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package store keeps the visor state in visor.db: documents (projects, workdirs, sessions, harness state, meta) and the event log.

Index

Constants

View Source
const (
	KindMeta    = "meta"
	KindProject = "project"
	KindWorkdir = "workdir"
	KindSession = "session"
	KindHarness = "harness"
)

Document kinds.

Variables

View Source
var ErrNotFound = errors.New("store: not found")

ErrNotFound reports a missing document.

Functions

This section is empty.

Types

type EventRow

type EventRow struct {
	Seq     uint64
	Session string
	Data    []byte
	// Source and SourceSeq name the holder run and the holder sequence of
	// an event that came from a holder.
	Source    string
	SourceSeq uint64
}

EventRow is one stored event.

type Store

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

Store is one open visor.db.

func Open

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

Open opens or creates the database at path with mode 0600.

func (*Store) AppendEvent

func (s *Store) AppendEvent(ctx context.Context, e EventRow) error

AppendEvent writes one event with its sequence number.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, kind, id string) error

Delete removes a document. A missing document is not an error.

func (*Store) DeleteSessionEvents

func (s *Store) DeleteSessionEvents(ctx context.Context, session string) error

DeleteSessionEvents removes the events of one session.

func (*Store) Events

func (s *Store) Events(ctx context.Context, after, until uint64, sessions []string, limit int) ([]EventRow, error)

Events reads the events with after < seq <= until, in order, at most limit rows. An empty sessions list reads all sessions.

func (*Store) Get

func (s *Store) Get(ctx context.Context, kind, id string) ([]byte, error)

Get reads a document. It returns ErrNotFound when there is none.

func (*Store) LastSeq

func (s *Store) LastSeq(ctx context.Context) (uint64, error)

LastSeq returns the highest sequence number, or 0.

func (*Store) LastSource

func (s *Store) LastSource(ctx context.Context, session string) (string, uint64, error)

LastSource gives the holder run and the holder sequence of the last event of a session that came from a holder. An empty run means none.

func (*Store) List

func (s *Store) List(ctx context.Context, kind string) ([][]byte, error)

List reads all documents of one kind, in id order.

func (*Store) Put

func (s *Store) Put(ctx context.Context, kind, id string, data []byte) error

Put writes a document.

Jump to

Keyboard shortcuts

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