pub async fn run_in_isolated_tx<F, Fut, T>(
pool: &PgPool,
isolation: TransactionIsolation,
body: F,
) -> Result<T, CoolError>where
F: FnMut(Transaction<'static, Postgres>) -> Fut,
Fut: Future<Output = Result<(T, Transaction<'static, Postgres>), CoolError>>,Expand description
Begin a transaction at the requested isolation level, run body against
the live transaction, and commit. On 40001 (serialization_failure) or
40P01 (deadlock_detected) the transaction is rolled back and the body
runs again, up to MAX_RETRIES_DEFAULT times. Other errors propagate
immediately.
body receives a mutable transaction reference; it should run all of
its SQL through that reference so the writes participate in the same
transaction.