Documentation
¶
Overview ¶
Package sqlitestream opens a SQLite database with PRAGMAs suitable for Litestream and, when a replica URL is configured via WithReplicaURL, restores the file from the replica if it's missing locally and runs continuous replication in the background.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Restore ¶
Restore is a one-shot restore from the replica (configured via WithReplicaURL) into outputPath. It refuses to overwrite an existing file unless force is true; with force the .db, .db-wal and .db-shm files are removed first to give SQLite a clean slate. Used by ops scripts and the `firehose restore` subcommand.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an open SQLite database, optionally with background Litestream replication.
Use SQL to access the underlying *sql.DB; call Close when done — Close flushes the final WAL segment to S3 if replication is on.
func Open ¶
Open opens path with PRAGMAs suitable for Litestream. If WithReplicaURL is supplied, the database is restored from the replica when missing locally and background replication is started before the SQL handle is opened.
type Option ¶
type Option func(*config)
Option configures Open and Restore.
func WithAWSCredentials ¶
WithCredentials sets credentials separately from the URL. Preferred over embedding "key:secret@" in the URL because URLs are easy to log or expose via process listings.
func WithLogger ¶
WithLogger sets the slog.Logger used for replication and restore events.
func WithReplicaURL ¶
WithReplicaURL configures the Litestream replica destination as a URL, e.g. "s3://bucket/path?region=us-east-1" or "file:///var/lib/replica". Empty disables replication entirely.