Documentation
¶
Overview ¶
Package sqlite keeps Aboard's data in SQLite: each board's append-only event log, the read models built from it (boards, members, join codes, messages), humans, browser logins, saved responses for idempotent writes and the server's own settings. It implements board's Store port and api's Responses port. Writes hold the write lock from the start, so event sequence numbers never race.
Index ¶
- Variables
- type Store
- func (s *Store) Close() error
- func (s *Store) PurgeResponses(ctx context.Context) error
- func (s *Store) Read(ctx context.Context, fn func(board.ReadTx) error) error
- func (s *Store) SaveResponse(ctx context.Context, scope, key string, r api.SavedResponse) error
- func (s *Store) SavedResponse(ctx context.Context, scope, key string) (api.SavedResponse, bool, error)
- func (s *Store) Setting(ctx context.Context, key string) (value string, ok bool, err error)
- func (s *Store) SettingOnce(ctx context.Context, key, value string) (string, error)
- func (s *Store) Write(ctx context.Context, fn func(board.Tx) error) error
Constants ¶
This section is empty.
Variables ¶
var ErrNewerSchema = errors.New("written by a newer aboard")
ErrNewerSchema means the data was written by a newer aboard, whose schema this one doesn't know; reading it could misread it, so Open refuses.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an open Aboard database.
func OpenReadOnly ¶ added in v0.1.3
OpenReadOnly opens an existing operator-selected database without creating or migrating it.
func (*Store) PurgeResponses ¶ added in v0.1.1
PurgeResponses removes expired answers. This is logical deletion; SQLite pages, WAL files and migration backups may still hold copies.
func (*Store) Read ¶
Read runs fn in a transaction that is always rolled back, so it sees one consistent state of the database.
func (*Store) SaveResponse ¶
SaveResponse stores the response to an idempotent write. If one is already saved for the key and has not expired, the first one is kept. An expired answer is replaced in the same transaction, so the new request has its own retry window.
func (*Store) SavedResponse ¶
func (s *Store) SavedResponse(ctx context.Context, scope, key string) (api.SavedResponse, bool, error)
SavedResponse finds the response saved for an idempotency key in a caller's scope, and reports whether it is still within its 24-hour lifetime.
func (*Store) SettingOnce ¶
SettingOnce stores a server setting unless it has a value already, and returns the value it has afterwards: value, or the one stored first. Stored values never change, so two servers starting at once on one database agree on the one that was kept.