Documentation ¶
Index ¶
- Variables
- func GetConn(ctx context.Context, db *gorm.DB) *gorm.DB
- func NewDBTxnMiddleware(db *gorm.DB, logger clogger.Logger) chttp.MiddlewareFunc
- func NewDBTxnMiddlewareFx(db *gorm.DB, logger clogger.Logger) chttp.GlobalMiddlewareFuncResult
- func NewGormDB(p GormDBParams) (*gorm.DB, error)
- type Config
- type DBTxnMiddleware
- type GormDBParams
Constants ¶
This section is empty.
Variables ¶
View Source
var Fx = fx.Provide( NewGormDB, NewDBTxnMiddlewareFx, )
Fx module that provides a connection to a Postgres DB using GORM. It also provides a middleware to wrap http requests into db transactions.
Functions ¶
func GetConn ¶
GetConn returns a db connection from the context or the given default connection if context is empty.
func NewDBTxnMiddleware ¶
func NewDBTxnMiddlewareFx ¶
Types ¶
type DBTxnMiddleware ¶
DBTxnMiddleware provides a middleware that wraps the http request in a database transaction. If the response status code is between 100-399, the transaction is committed, else a rollback is performed.
Click to show internal directories.
Click to hide internal directories.