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) 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 (*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, the first one is kept, so every retry replays the same answer.
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 there was one.
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.