infrastructure

package
v0.0.0-...-b2f7bc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewGormDB

func NewGormDB(c *conf.Data, logger log.Logger) (*gorm.DB, error)

func NewGormLogAdapter

func NewGormLogAdapter(logger log.Logger) logger.Interface

func NewKnowledgeRepo

func NewKnowledgeRepo(data *Data, logger log.Logger) biz.KnowledgeRepoIf

NewKnowledgeRepo .

func NewTransaction

func NewTransaction(d *Data) biz.Transaction

NewTransaction .

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

func NewData

func NewData(c *conf.Data, logger log.Logger) (*Data, func(), error)

func (*Data) DB

func (d *Data) DB(ctx context.Context) *gorm.DB

DB 根据此方法来判断当前的 db 是不是使用 事务的 DB

func (*Data) ExecTx

func (d *Data) ExecTx(ctx context.Context, fn func(ctx context.Context) error) error

ExecTx gorm Transaction

type GormLogAdapter

type GormLogAdapter struct {
	Logger log.Logger
}

func (*GormLogAdapter) Error

func (g *GormLogAdapter) Error(ctx context.Context, msg string, data ...interface{})

func (*GormLogAdapter) Info

func (g *GormLogAdapter) Info(ctx context.Context, msg string, data ...interface{})

func (*GormLogAdapter) LogMode

func (*GormLogAdapter) Trace

func (g *GormLogAdapter) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*GormLogAdapter) Warn

func (g *GormLogAdapter) Warn(ctx context.Context, msg string, data ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL