diff options
author | Alex <alex@adnab.me> | 2023-09-21 14:03:35 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-09-21 14:03:35 +0000 |
commit | 1d986bd889a5f5fe1bdc75e7d4b34acc2cfbe09f (patch) | |
tree | 5b5f8d66637c4a10866b00e07a45081c93cf75cf /src/db/sqlite_adapter.rs | |
parent | fd7d8fec59c617b40e480ff855894cf35fdcfb40 (diff) | |
parent | 0635250b2bdcce4156704128de154f9052d34e9e (diff) | |
download | garage-1d986bd889a5f5fe1bdc75e7d4b34acc2cfbe09f.tar.gz garage-1d986bd889a5f5fe1bdc75e7d4b34acc2cfbe09f.zip |
Merge pull request 'Refactor db transactions and add on_commit for table.queue_insert' (#637) from k2v-indices-lmdb into next
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/637
Diffstat (limited to 'src/db/sqlite_adapter.rs')
-rw-r--r-- | src/db/sqlite_adapter.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index 63b4506e..9f967c66 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -9,8 +9,8 @@ use std::sync::{Arc, Mutex, MutexGuard}; use rusqlite::{params, Connection, Rows, Statement, Transaction}; use crate::{ - Db, Error, IDb, ITx, ITxFn, Result, TxError, TxFnResult, TxOpError, TxOpResult, TxResult, - TxValueIter, Value, ValueIter, + Db, Error, IDb, ITx, ITxFn, OnCommit, Result, TxError, TxFnResult, TxOpError, TxOpResult, + TxResult, TxValueIter, Value, ValueIter, }; pub use rusqlite; @@ -261,7 +261,7 @@ impl IDb for SqliteDb { // ---- - fn transaction(&self, f: &dyn ITxFn) -> TxResult<(), ()> { + fn transaction(&self, f: &dyn ITxFn) -> TxResult<OnCommit, ()> { trace!("transaction: lock db"); let mut this = self.0.lock().unwrap(); trace!("transaction: lock acquired"); @@ -277,9 +277,9 @@ impl IDb for SqliteDb { trees: &this_mut_ref.trees, }; let res = match f.try_on(&mut tx) { - TxFnResult::Ok => { + TxFnResult::Ok(on_commit) => { tx.tx.commit().map_err(Error::from).map_err(TxError::Db)?; - Ok(()) + Ok(on_commit) } TxFnResult::Abort => { tx.tx.rollback().map_err(Error::from).map_err(TxError::Db)?; |