Files
db-sqlite/provider.go
T

19 lines
721 B
Go
Raw Permalink Normal View History

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
}