# Package-level declarations

## Types

RollbackContext
Link copied to clipboard
class RollbackContext < T >

Context provided to rollback actions, containing both the successful result of the action and the error that triggered the rollback.

TransactionDSLRollbackLambda
Link copied to clipboard
typealias TransactionDSLRollbackLambda = suspend ( Throwable ) -> Unit

Type alias for a suspending rollback lambda that receives the error that triggered the rollback.

TransactionsDSL
Link copied to clipboard
class TransactionsDSL

DSL context for defining transactional operations with automatic rollback on failure. This class manages a list of rollback actions that will be executed in reverse order if an error occurs.

## Functions

doSuspendTransaction
Link copied to clipboard
suspend fun < T > doSuspendTransaction (onRollbackStepError: suspend ( Throwable ) -> Unit = { }, block: suspend TransactionsDSL .() -> T ): Result < T >

Starts transaction with opportunity to add actions rollableBackOperation. How to use:

rollableBackOperation
Link copied to clipboard
suspend fun < T > TransactionsDSL . rollableBackOperation (rollback: suspend RollbackContext < T >.() -> Unit , action: suspend () -> T ): T

Calls action and, if it succeeded - saving rollback action for future usage for cases when some other action or even main one throwing an error