Documentation
¶
Overview ¶
Package sqlite opens a file-backed SQLite database with a serialized writer, a query-only read pool, and optional buffered asynchronous writes.
Index ¶
- Variables
- type DB
- func (d *DB) Close() error
- func (d *DB) ExecAsync(statement string, args ...any) error
- func (d *DB) InsertAsync(table string, values map[string]any) error
- func (d *DB) InsertTableAsync(table sqlitetable.Table, rows []query.Row) error
- func (d *DB) Lease() func()
- func (d *DB) Path() string
- func (d *DB) ReadDSN() string
- func (d *DB) Reader() *sql.DB
- func (d *DB) Write(mutation Mutation) error
- func (d *DB) WriteAsync(mutation Mutation) error
- type Mutation
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is returned when a write is submitted after Close starts. ErrClosed = errors.New("sqlite database is closed") // ErrWriteQueueFull is returned when the asynchronous write queue is full. ErrWriteQueueFull = errors.New("sqlite asynchronous write queue is full") // ErrWriteErrorHandlerRequired is returned when an asynchronous write has no error handler. ErrWriteErrorHandlerRequired = errors.New("sqlite asynchronous writes require OnWriteError") )
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB owns separate SQLite read and write pools over one file.
func (*DB) InsertAsync ¶
InsertAsync queues one map-shaped row for insertion into table.
func (*DB) InsertTableAsync ¶
InsertTableAsync queues typed rows for insertion through sqlitetable.Table.
func (*DB) Lease ¶
func (d *DB) Lease() func()
Lease prevents mutations until the returned release function is called.
func (*DB) Reader ¶
Reader returns the query-only read pool. Callers that require several statements to observe one stable mutation boundary must hold Lease as well.
func (*DB) WriteAsync ¶
WriteAsync queues mutation for an asynchronous batch buffered for 100 milliseconds. It returns ErrWriteQueueFull rather than blocking.