19 lines
721 B
Go
19 lines
721 B
Go
|
|
package sqlite
|
||
|
|
|
||
|
|
import "context"
|
||
|
|
|
||
|
|
// Provider is the database access interface consumed by repositories and services.
|
||
|
|
// All methods are safe for concurrent use.
|
||
|
|
type Provider interface {
|
||
|
|
// GetExecutor returns the active transaction injected by [UnitOfWork] if one
|
||
|
|
// is present in ctx, otherwise returns the connection pool.
|
||
|
|
GetExecutor(ctx context.Context) Executor
|
||
|
|
// Begin starts a new transaction.
|
||
|
|
Begin(ctx context.Context) (Tx, error)
|
||
|
|
// Ping verifies that the database connection is alive.
|
||
|
|
Ping(ctx context.Context) error
|
||
|
|
// HandleError maps a database/sql or SQLite error to a typed [xerrors] value.
|
||
|
|
// Call this at every point where a database error is first observed.
|
||
|
|
HandleError(err error) error
|
||
|
|
}
|