Documentation
¶
Overview ¶
Package sqlitepool implements a pool of SQLite database connections.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
A Pool is a fixed-size pool of SQLite database connections. One is reserved for writable transactions, the others are used for read-only transactions.
func NewPool ¶
func NewPool(filename string, poolSize int, initFn func(sqliteh.DB) error, tracer sqliteh.Tracer) (_ *Pool, err error)
NewPool creates a Pool of poolSize database connections.
For each connection, initFn is called to initialize the connection. Tracer is used to report statistics about the use of the Pool.
func (*Pool) BeginRx ¶
BeginRx creates a read-only transaction. The parameter why is passed to the Tracer for debugging.
type Rx ¶
type Rx struct {
// OnRollback is an optional function called after rollback.
// If Rx is part of a Tx and it is committed, then OnRollback
// is not called.
OnRollback func()
// contains filtered or unexported fields
}
Rx is a read-only transaction.
It is *not* safe for concurrent use.
func (*Rx) DB ¶
DB returns the underlying database connection.
Be careful: a transaction is in progress. Any use of BEGIN/COMMIT/ROLLBACK should be modelled as a nested transaction, and when done the original outer transaction should be left in-progress.
type Tx ¶
type Tx struct {
*Rx
// OnCommit is an optional function called after successful commit.
OnCommit func()
}
Tx is a writable SQLite database transaction.
It is *not* safe for concurrent use.
A Tx contains an embedded Rx, which can be used to pass to functions that want to perform read-only queries on the writable Tx.