Documentation ¶
Index ¶
- Constants
- func CopyDBResources(input, output DB, overrideExisting bool) error
- func GetRetryInterval(retryInterval time.Duration) time.Duration
- func InitDBConnWithSchemas(aDb DB, initDBParams InitDBParams) error
- func InitDBWithSchemas(dbType, dbConnection string, initDBParams InitDBParams) error
- func IsDeadlock(err error) bool
- func Within(db DB, fn func(transaction.Transaction) error) error
- func WithinTemplate(retries int, retryStrategy func() time.Duration, ...) error
- func WithinTx(ctx context.Context, db DB, options *transaction.TxOptions, ...) error
- type DB
- type ITransaction
- type InitDBParams
Constants ¶
View Source
const DefaultMaxOpenConn = 100
DefaultMaxOpenConn will applied for db object
Variables ¶
This section is empty.
Functions ¶
func CopyDBResources ¶
CopyDBResources copies resources from input database to output database
func InitDBConnWithSchemas ¶
func InitDBConnWithSchemas(aDb DB, initDBParams InitDBParams) error
InitDBConnWithSchemas initializes database connection using schemas stored in Manager
func InitDBWithSchemas ¶
func InitDBWithSchemas(dbType, dbConnection string, initDBParams InitDBParams) error
InitDBWithSchemas initializes database using schemas stored in Manager
func Within ¶
func Within(db DB, fn func(transaction.Transaction) error) error
Within executes a scoped transaction on a database
func WithinTemplate ¶
func WithinTemplate( retries int, retryStrategy func() time.Duration, beginStrategy func() (ITransaction, error), fn func(ITransaction) error, ) error
func WithinTx ¶
func WithinTx(ctx context.Context, db DB, options *transaction.TxOptions, fn func(transaction.Transaction) error) error
WithinTx executes a scoped transaction with options on a database
Types ¶
type DB ¶
type DB interface { Connect(string, string, int) error Close() Begin() (transaction.Transaction, error) BeginTx(ctx context.Context, options *transaction.TxOptions) (transaction.Transaction, error) RegisterTable(s *schema.Schema, cascade, migrate bool) error DropTable(*schema.Schema) error // options Options() options.Options }
DB is a common interface for handing db
type ITransaction ¶
ITransaction is a common interface for transaction
type InitDBParams ¶
type InitDBParams struct {
DropOnCreate, Cascade, AutoMigrate, AllowEmpty bool
}
func DefaultTestInitDBParams ¶
func DefaultTestInitDBParams() InitDBParams
Click to show internal directories.
Click to hide internal directories.