Documentation
¶
Overview ¶
Package sqlite provides a durable, embedded stream.Service backed by SQLite.
Use it with any database/sql SQLite driver (modernc.org/sqlite, mattn/go-sqlite3). The caller is responsible for opening the *sql.DB; stream/sqlite does not own the connection lifetime.
SQLite has no FOR UPDATE SKIP LOCKED. Claim queries run inside a BEGIN IMMEDIATE transaction; concurrent claimers serialize on the database write lock. This is fine for embedded single-process workloads. For high throughput across many processes, use the pgx backend instead.
The database should be opened with WAL mode and a non-trivial busy_timeout for adequate write throughput. Recommended DSN suffix: "?_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=busy_timeout(5000)"
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("stream/sqlite: service closed")
ErrClosed is returned by Publish or Subscribe after Close.
var Schema string
Functions ¶
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the SQLite stream.Service implementation.
func New ¶
func New(db *sql.DB, opts ...stream.ServiceOption) *Service
New constructs a stream/sqlite Service. The caller owns db.
func (*Service) Close ¶
Close shuts down all consumers. Idempotent. ctx bounds the overall close: cancellation aborts before the next consumer is drained and returns ctx.Err() — already-drained consumers stay drained.