Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrDuplicateKey = errors.New("duplicate dbKey") ErrDbKeyNotFound = errors.New("dbKey not found") )
View Source
var (
ErrUnitOfWorkNotFound = errors.New("unit of work not found, please wrap with manager.WithNew")
)
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager interface {
Register(key string, f DbFactory) (err error)
RegisterIfNot(key string, f DbFactory)
Resolve(ctx context.Context, key string) (db TransactionalDb, ok bool)
// WithNew create a new unit of work and execute [fn] with this unit of work
WithNew(ctx context.Context, fn func(ctx context.Context) error, opt ...*sql.TxOptions) error
}
func NewManager ¶
func NewManager() Manager
type TransactionalDb ¶
type UnitOfWork ¶
type UnitOfWork interface {
Commit() error
Rollback() error
GetTxDb(ctx context.Context, key string) (tx interface{}, err error)
}
func FromCurrentUow ¶
func FromCurrentUow(ctx context.Context) (u UnitOfWork, ok bool)
func NewUnitOfWork ¶
func NewUnitOfWork(m Manager, opt ...*sql.TxOptions) UnitOfWork
Click to show internal directories.
Click to hide internal directories.