Documentation
¶
Overview ¶
Package ltx provides logical transactions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrFinished = errors.New("ltx: transaction has already finished")
ErrFinished is returned when operating on a finished transaction.
Functions ¶
This section is empty.
Types ¶
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a logical transaction.
func (*Tx) Commit ¶
Commit ends the transaction, making any call to Rollback a noop. If the transaction is already finished, Commit returns ErrFinished.
func (*Tx) Compensate ¶
Compensate adds a compensation function to be called on rollback and returns a cancel function to deactivate the compensation and ErrFinished if the transaction is already finished. If the compensation is canceled, it will not be called during rollback. Calls after the transaction is finished (committed or rolled back) are a noop.
type TxOption ¶
TxOption configures a transaction.
func WithParallelCleanup ¶
func WithParallelCleanup() TxOption
WithParallelCleanup runs rollback compensations concurrently.
func WithRollbackIgnoresCancel ¶
func WithRollbackIgnoresCancel() TxOption
WithRollbackIgnoresCancel ensures compensations run even if ctx is canceled.
func WithRollbackTimeout ¶
WithRollbackTimeout sets the context timeout for compensations during rollback.