Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Tx ¶
type Tx interface { driver.Tx driver.QueryerContext driver.ExecerContext }
type TxDoer ¶
TxDoer contains options for retrying transactions.
func (TxDoer) Do ¶
func (d TxDoer) Do(ctx context.Context, f TxOperationFunc) (err error)
Do starts a transaction and calls f with it. If f() call returns a retryable error, it repeats it accordingly to retry configuration that TxDoer's DB driver holds.
Note that callers should mutate state outside f carefully and keeping in mind that f could be called again even if no error returned – transaction commitment can be failed:
var results []int ydb.DoTx(x, db, TxOperationFunc(func(x context.Context, tx *conn.Tx) error { // Reset resulting slice to prevent duplicates when retry occurred. results = results[:0] rows, err := tx.QueryContext(...) if err != nil { // handle error } for rows.Next() { results = append(results, ...) } return rows.Err() }))
Click to show internal directories.
Click to hide internal directories.