Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrExcessiveContention is used to signal that even after retrying, the transaction operations // could not be successfully applied due to database contention. ErrExcessiveContention = stderrors.New("state changing too quickly; try again soon") // ErrNoOperations is returned by TransactionSource implementations to signal that // no transaction operations are available to run. ErrNoOperations = stderrors.New("no transaction operations are available") // ErrNoOperations is returned by TransactionSource implementations to signal that // the transaction list could not be built but the caller should retry. ErrTransientFailure = stderrors.New("transient failure") )
Functions ¶
Types ¶
type Runner ¶
type Runner interface { // RunTransaction applies the specified transaction operations to a database. RunTransaction(ops []txn.Op) error // Run calls the nominated function to get the transaction operations to apply to a database. // If there is a failure due to a txn.ErrAborted error, the attempt is retried up to nrRetries times. Run(transactions TransactionSource) error // ResumeTransactions resumes all pending transactions. ResumeTransactions() error }
Runner instances applies operations to collections in a database.
func NewRunner ¶
func NewRunner(params RunnerParams) Runner
NewRunner returns a Runner which runs transactions for the database specified in params. Collection names used to manage the transactions and change log may also be specified in params, but if not, default values will be used.
type RunnerParams ¶
type RunnerParams struct { // Database is the mgo database for which the transaction runner will be used. Database *mgo.Database // TransactionCollectionName is the name of the collection // used to initialise the underlying mgo transaction runner, // defaults to "txns" if unspecified. TransactionCollectionName string // ChangeLogName is the mgo transaction runner change log, // defaults to "txns.log" if unspecified. ChangeLogName string }
RunnerParams are used to construct a new transaction runner. Only the Database value is mandatory, defaults will be used for the other attributes if not specified.
Click to show internal directories.
Click to hide internal directories.