Documentation
¶
Index ¶
- Constants
- type Config
- type ConfigDataSource
- type ContextKey
- type Dialect
- type Registry
- type SqlDataSource
- type SqlDataSourceStd
- type SqlExecutor
- type TransactionFinalizer
- type TransactionStarter
- type UnitOfWork
- func (uow *UnitOfWork) Bind(context context.Context, txScope TransactionFinalizer)
- func (uow *UnitOfWork) Close() error
- func (uow *UnitOfWork) Commit() error
- func (uow *UnitOfWork) Context() context.Context
- func (uow *UnitOfWork) TxScope() TransactionFinalizer
- func (uow *UnitOfWork) Use(fn func(TransactionFinalizer) any)
Constants ¶
View Source
const DefaultDB = "DEFAULT"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Sources map[string]ConfigDataSource `conf:"SOURCES"`
}
type ConfigDataSource ¶
type ConfigDataSource struct {
DSN string `conf:"DSN"`
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) AddConnection ¶
func (*Registry) GetDefaultSql ¶
func (registry *Registry) GetDefaultSql() SqlDataSource
func (*Registry) GetNamedSql ¶
func (registry *Registry) GetNamedSql(name string) SqlDataSource
type SqlDataSource ¶
type SqlDataSource interface {
GetConnection() SqlExecutor
UseUnitOfWork(ctx context.Context) (*UnitOfWork, error)
}
type SqlDataSourceStd ¶
type SqlDataSourceStd struct {
// contains filtered or unexported fields
}
func NewSqlDataSourceStd ¶
func (*SqlDataSourceStd) GetConnection ¶
func (dataSource *SqlDataSourceStd) GetConnection() SqlExecutor
func (*SqlDataSourceStd) UseUnitOfWork ¶
func (dataSource *SqlDataSourceStd) UseUnitOfWork(ctx context.Context) (*UnitOfWork, error)
type SqlExecutor ¶
type SqlExecutor interface {
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}
type TransactionFinalizer ¶
type TransactionStarter ¶
type UnitOfWork ¶
type UnitOfWork struct {
// contains filtered or unexported fields
}
func UseUnitOfWork ¶
func UseUnitOfWork(ctx context.Context, transactionStarter TransactionStarter) (*UnitOfWork, error)
func (*UnitOfWork) Bind ¶
func (uow *UnitOfWork) Bind(context context.Context, txScope TransactionFinalizer)
func (*UnitOfWork) Close ¶
func (uow *UnitOfWork) Close() error
func (*UnitOfWork) Commit ¶
func (uow *UnitOfWork) Commit() error
func (*UnitOfWork) Context ¶
func (uow *UnitOfWork) Context() context.Context
func (*UnitOfWork) TxScope ¶
func (uow *UnitOfWork) TxScope() TransactionFinalizer
func (*UnitOfWork) Use ¶
func (uow *UnitOfWork) Use(fn func(TransactionFinalizer) any)
Click to show internal directories.
Click to hide internal directories.