Documentation
¶
Overview ¶
Package sqlite provides a durable SQLite-backed EventStore implementation. Uses modernc.org/sqlite (pure Go, no cgo). WAL mode and PRAGMA synchronous=FULL provide crash safety. Single-writer per loop is enforced by expectedLastSeq optimistic concurrency.
Index ¶
- type Option
- type Store
- func (s *Store) Append(ctx context.Context, id event.LoopID, expectedLastSeq uint64, ...) error
- func (s *Store) Close() error
- func (s *Store) Get(ctx context.Context, key string) ([]byte, error)
- func (s *Store) LatestSnapshot(ctx context.Context, id event.LoopID) (event.Snapshot, bool, error)
- func (s *Store) List(ctx context.Context, f runtime.ListFilter) ([]runtime.LoopMeta, error)
- func (s *Store) Load(ctx context.Context, id event.LoopID, fromSeq uint64) iter.Seq2[event.Envelope, error]
- func (s *Store) Put(ctx context.Context, loopID event.LoopID, seq uint64, data []byte) (string, error)
- func (s *Store) SaveSnapshot(ctx context.Context, snap event.Snapshot) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Store)
Option configures the Store.
func WithSynchronous ¶
WithSynchronous sets the SQLite synchronous mode (default: FULL). Use "NORMAL" for better performance at the cost of some durability guarantee (still crash-safe with WAL in most cases).
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the SQLite-backed EventStore. Thread-safe (SQLite handles concurrent access).
func (*Store) Append ¶
func (s *Store) Append(ctx context.Context, id event.LoopID, expectedLastSeq uint64, evs []event.Envelope) error
Append appends evs to the event log. Returns ErrConflict if expectedLastSeq is wrong.
func (*Store) LatestSnapshot ¶
LatestSnapshot returns the most recent snapshot for loop id.
func (*Store) Load ¶
func (s *Store) Load(ctx context.Context, id event.LoopID, fromSeq uint64) iter.Seq2[event.Envelope, error]
Load returns an iterator over events for loop id starting at fromSeq.
func (*Store) Put ¶
func (s *Store) Put(ctx context.Context, loopID event.LoopID, seq uint64, data []byte) (string, error)
Put stores data in the artifacts table and returns a key of the form "<loopID>/<seq>". Keys are unique per (loop_id, seq) pair — callers must ensure uniqueness or use a counter suffix when multiple artifacts per seq are possible.