Last active
July 23, 2019 12:27
-
-
Save jfeng45/3326625cbc6a8a11e0bb78d489296e7e to your computer and use it in GitHub Desktop.
transaction interface for database handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Transactioner is the transaction interface for database handler | |
// It should only be applicable to SQL database | |
type Transactioner interface { | |
// Rollback a transaction | |
Rollback() error | |
// Commit a transaction | |
Commit() error | |
// TxEnd commits a transaction if no errors, otherwise rollback | |
// txFunc is the operations wrapped in a transaction | |
TxEnd(txFunc func() error) error | |
// TxBegin gets *sql.DB from receiver and return a SqlGdbc, which has a *sql.Tx | |
TxBegin() (SqlGdbc, error) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment