Documentation
¶
Overview ¶
Package gormdb provides the database-agnostic core for GORM integration.
It defines the generic DBClient wrapper, configuration options, transaction management, and monitoring hooks. This package is designed to be used in conjunction with a driver-specific implementation (e.g., gormpg for PostgreSQL, gormmysql for MySQL), which provides the specific dialector and connection logic.
This separation of concerns allows for easy extensibility to support multiple database drivers while reusing the core GORM interaction logic.
Index ¶
- func AcquireAdvisoryLock(ctx context.Context, tx *gorm.DB, lockID int) error
- func NewDeleter[R any](db *DBClient) *deleter[R]
- func NewTransactioner(db *DBClient, log logger.Logger) *transactioner
- func ReleaseAdvisoryLock(ctx context.Context, tx *gorm.DB, lockID int) error
- type DBClient
- type MonitorOption
- type Option
- func WithDefaultTransaction(enabled bool) Option
- func WithMonitorOpts(options ...MonitorOption) Option
- func WithNestedTransactions(enabled bool) Option
- func WithNowFunc(f func() time.Time) Option
- func WithSQLConnectionOptions(options ...sqldb.ConnectionOption) Option
- func WithSingularTable(enabled bool) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireAdvisoryLock ¶
AcquireAdvisoryLock acquires a PostgreSQL advisory lock using the provided transaction.
func NewDeleter ¶
func NewTransactioner ¶
Types ¶
type DBClient ¶
DBClient implements a sqldb.Client using gorm.
func (*DBClient) PingContext ¶
PingContext pings the database with the given context (helpful for healthchecking purposes).
type MonitorOption ¶
type MonitorOption func(c *monitorConfig)
func SlowQueriesThreshold ¶
func SlowQueriesThreshold(slowQueryThreshold time.Duration) MonitorOption
type Option ¶
type Option func(*config) error
Option defines the contract for options applied to a gormdb.DBClient.
func WithDefaultTransaction ¶
func WithMonitorOpts ¶
func WithMonitorOpts(options ...MonitorOption) Option
func WithNestedTransactions ¶
func WithNowFunc ¶
func WithSQLConnectionOptions ¶
func WithSQLConnectionOptions(options ...sqldb.ConnectionOption) Option