Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnitOfWorkNotFound = errors.New("unit of work not found, please wrap with manager.WithNew")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { NestedTransaction bool Formatter KeyFormatter }
type DbFactory ¶
type DbFactory func(ctx context.Context, keys ...string) TransactionalDb
DbFactory resolve transactional db by database keys
type KeyFormatter ¶
var ( DefaultKeyFormatter KeyFormatter = func(keys ...string) string { return strings.Join(keys, "/") } )
type Manager ¶
type Manager interface { // 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 ¶
type Option ¶
type Option func(*Config)
func WithKeyFormatter ¶
func WithKeyFormatter(f KeyFormatter) Option
func WithNestedNestedTransaction ¶
func WithNestedNestedTransaction() Option
type TransactionalDb ¶
type UnitOfWork ¶
type UnitOfWork struct {
// contains filtered or unexported fields
}
func FromCurrentUow ¶
func FromCurrentUow(ctx context.Context) (u *UnitOfWork, ok bool)
func NewUnitOfWork ¶
func NewUnitOfWork(factory DbFactory, formatter KeyFormatter, opt ...*sql.TxOptions) *UnitOfWork
func (*UnitOfWork) Commit ¶
func (u *UnitOfWork) Commit() error
func (*UnitOfWork) Rollback ¶
func (u *UnitOfWork) Rollback() error
Click to show internal directories.
Click to hide internal directories.