Documentation
¶
Index ¶
- Variables
- func AddToCtx(ctx context.Context, db bun.IDB) context.Context
- func AddToCtxWithLane(ctx context.Context, db bun.IDB, name string) context.Context
- func GetDBFromCtx(ctx context.Context) bun.IDB
- func GetDBFromCtxLane(ctx context.Context, lane string) bun.IDB
- func NewDB(conf config.Config, lf log.LoggerFactory) (*bun.DB, error)
- func OnDBStop(ctx context.Context, db *bun.DB) error
- func OpenSqlDB(conf config.Config, dbName string, lf log.LoggerFactory) (*sql.DB, error)
- func RunInTx(ctx context.Context, fn func(ctx context.Context) error) error
- func RunInTxWithOpts(ctx context.Context, opts *sql.TxOptions, fn func(ctx context.Context) error) error
- func WithLane(ctx context.Context, lane string) context.Context
- func WrapWithBun(conf config.Config, slqDB *sql.DB) *bun.DB
- type BunLogger
- type Tx
Constants ¶
This section is empty.
Variables ¶
View Source
var FxExport = di.FxProvideAs[bun.IDB](NewDB, []fx.Annotation{fx.OnStop(OnDBStop)}, nil)
Functions ¶
func AddToCtxWithLane ¶
func RunInTxWithOpts ¶
func WithLane ¶
WithLane adds a lane-specific DB to the context. It retrieves the current DB from the context and adds a new entry with the lane name as part of the key. This allows for multiple lanes to have their own DB instances in the same context, which can be useful for handling different database connections or transactions. Calls to GetDBFromCtx on the returned context will use the lane specific DB instead of the default one. If name is empty, then the original context is returned.
Types ¶
type BunLogger ¶
type BunLogger struct{}
func (*BunLogger) AfterQuery ¶
func (l *BunLogger) AfterQuery(ctx context.Context, event *bun.QueryEvent)
func (*BunLogger) BeforeQuery ¶
Click to show internal directories.
Click to hide internal directories.