Documentation ¶
Overview ¶
The txnmanager is a nested transation manager for database/sql. This software is released under the MIT License, see https://github.com/shogo82148/txmanager/blob/master/LICENSE.txt .
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrChildrenNotDone = errors.New("txmanager: children transactions are not done")
Functions ¶
Types ¶
type Beginner ¶
type Beginner interface { // TxBegin starts a transaction. // If the DB is not a transaction, TxBegin does BEGIN at here. // Otherwise, its behavior is implementation-dependent. TxBegin() (Tx, error) }
a Beginner starts a transaction.
type Committer ¶
type Committer interface { // TxCommit commits the transaction. // If the DB is in a root transaction, TxCommit does COMMIT at here. // Otherwise, its behavior is implementation-dependent. TxCommit() error // TxRollback aborts the transaction. // If the DB is in a root transaction, TxRollback does ROLLBACK at here. // Otherwise, its behavior is implementation-dependent. TxRollback() error // TxFinish aborts the transaction if it is not commited. TxFinish() error }
a Committer finishes a transaction
type EndHookAdder ¶
type EndHookAdder interface { // TxAddEndHook add a hook function to txmanager. // Hooks are executed only all transactions are executed successfully. // If some transactions are failed, they aren't executed. TxAddEndHook(hook func() error) error }
an EndHookAdder adds end hooks
type Executor ¶
type Executor interface { // Exec executes a query without returning any rows. // See sql.DB and sql.Tx for more information. Exec(query string, args ...interface{}) (sql.Result, error) // Prepare creates a prepared statement for later queries or executions. // See sql.DB and sql.Tx for more information. Prepare(query string) (*sql.Stmt, error) // Query executes a query that returns rows, typically a SELECT. // See sql.DB and sql.Tx for more information. Query(query string, args ...interface{}) (*sql.Rows, error) // QueryRow executes a query that is expected to return at most one row. // See sql.DB and sql.Tx for more information. QueryRow(query string, args ...interface{}) *sql.Row }
an Executor executes SQL query.
Click to show internal directories.
Click to hide internal directories.