OperationTransactionParticipant
Interface: OperationTransactionParticipant
Defined in: packages/core/src/core/transactions.ts:20
A resource taking part in the transaction of an operation (a database connection, a session...)
callOperation drives the lifecycle of the outermost operation: begin after the input and permission
checks and before Webda.BeforeOperation, commit once the method resolved (a streamed result fully
written) and before Webda.OperationSuccess, rollback on any failure, before Webda.OperationFailure.
Nested operations join the outer transaction: they never begin nor finish it.
Participants keep their per-transaction state in the OperationTransaction slots
(useOperationTransaction().set(key, state)), and must be idempotent: commit or rollback may be called on a
participant that never opened anything, and rollback is called on a participant whose commit failed.
Properties
name
readonlyname:string
Defined in: packages/core/src/core/transactions.ts:24
Name, used in logs
Methods
begin()
begin(
context,operation?):Promise<void>
Defined in: packages/core/src/core/transactions.ts:32
Start the participation: open lazily when possible (an operation that never uses the resource should cost nothing)
Parameters
context
the execution context
operation?
the operation definition, undefined outside an operation (runWithTransaction);
operation.transaction === false asks the participant to stay out
Returns
Promise<void>
commit()
commit(
context):Promise<void>
Defined in: packages/core/src/core/transactions.ts:37
Commit the work, then release the resources whatever the outcome
Parameters
context
the execution context
Returns
Promise<void>
rollback()
rollback(
context,error):Promise<void>
Defined in: packages/core/src/core/transactions.ts:43
Roll back the work, then release the resources whatever the outcome
Parameters
context
the execution context
error
unknown
the error failing the operation
Returns
Promise<void>