Documentation ¶
Index ¶
- func DropAllTables(db *sql.DB) error
- func ErrHasCode(err error, code string) bool
- func ErrIsDuplicateKey(err error) bool
- func ErrIsForeignKey(err error) bool
- func ErrIsSerializationFailure(err error) bool
- func Migrate(db *sql.DB, migrationFS embed.FS) error
- func WithTx(db *sql.DB, fn func(*sql.Tx) error) error
- func WithTxDefault(db *sql.DB, fn func(*sql.Tx) error) error
- type SerialTxRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropAllTables ¶
Deletes all tables in the database. Useful for testing.
func ErrHasCode ¶
func ErrIsDuplicateKey ¶
func ErrIsForeignKey ¶
func ErrIsSerializationFailure ¶ added in v0.6.0
Types ¶
type SerialTxRunner ¶
SerialTxRunner attempts serializable transactions in a loop. If a transaction fails due to a serialization error, then the runner will retry with exponential backoff, until the sleep time reaches MaxTimeout.
For example, if MinTimeout is 100 ms, and MaxTimeout is 800 ms, it may sleep for ~100, 200, 400, and 800 ms between retries.
10% jitter is added to the sleep time.
Click to show internal directories.
Click to hide internal directories.