TxAPI()

An API whose response is computed inside a transaction.

new TxAPI()

Methods

async postCommit(respData) → {*}

Called after the transaction commits (and ONLY if it commits successfully). May alter the response by returning a new response value, or throwing RequestDone.
Parameters:
Name Type Description
respData * the response data
Returns:
* - the (possibly updated) response data

async preCommit(respData) → {*}

Called just before the transaction ATTEMPTS to commit. May alter the response by returning a new response value, or throwing RequestDone. Throwing an error will be propagated and handled by Transaction.run(), and will prevent the transaction from committing (unless the error is retryable).
Parameters:
Name Type Description
respData * the response data
Returns:
* - the (possibly updated) response data

async preTxStart()

Called just before the transaction starts. Useful to do async computation outside the transaction (reducing the window for contention).