aboutsummaryrefslogtreecommitdiff
path: root/src/db/sled_adapter.rs
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2023-10-10 13:28:28 +0000
committerAlex <alex@adnab.me>2023-10-10 13:28:28 +0000
commite6df7089a19d06696ac2178a4dae7ac9f27fd55e (patch)
treee1f7120d582f67fd104dc8e746d883befffb4daa /src/db/sled_adapter.rs
parente75fe2157d0973eb4320bbc87be5e54a1cb91a63 (diff)
parent952c9570c494468643353ee1ae9052b510353665 (diff)
downloadgarage-e6df7089a19d06696ac2178a4dae7ac9f27fd55e.tar.gz
garage-e6df7089a19d06696ac2178a4dae7ac9f27fd55e.zip
Merge pull request 'Garage v0.9' (#473) from next into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/473
Diffstat (limited to 'src/db/sled_adapter.rs')
-rw-r--r--src/db/sled_adapter.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs
index cf61867d..84f2001b 100644
--- a/src/db/sled_adapter.rs
+++ b/src/db/sled_adapter.rs
@@ -10,8 +10,8 @@ use sled::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 sled;
@@ -38,7 +38,15 @@ pub struct SledDb {
}
impl SledDb {
+ #[deprecated(
+ since = "0.9.0",
+ note = "The Sled database is now deprecated and will be removed in Garage v1.0. Please migrate to LMDB or Sqlite as soon as possible."
+ )]
pub fn init(db: sled::Db) -> Db {
+ tracing::warn!("-------------------- IMPORTANT WARNING !!! ----------------------");
+ tracing::warn!("The Sled database is now deprecated and will be removed in Garage v1.0.");
+ tracing::warn!("Please migrate to LMDB or Sqlite as soon as possible.");
+ tracing::warn!("-----------------------------------------------------------------------");
let s = Self {
db,
trees: RwLock::new((Vec::new(), HashMap::new())),
@@ -158,7 +166,7 @@ impl IDb for SledDb {
// ----
- fn transaction(&self, f: &dyn ITxFn) -> TxResult<(), ()> {
+ fn transaction(&self, f: &dyn ITxFn) -> TxResult<OnCommit, ()> {
let trees = self.trees.read().unwrap();
let res = trees.0.transaction(|txtrees| {
let mut tx = SledTx {
@@ -166,9 +174,9 @@ impl IDb for SledDb {
err: Cell::new(None),
};
match f.try_on(&mut tx) {
- TxFnResult::Ok => {
+ TxFnResult::Ok(on_commit) => {
assert!(tx.err.into_inner().is_none());
- Ok(())
+ Ok(on_commit)
}
TxFnResult::Abort => {
assert!(tx.err.into_inner().is_none());
@@ -181,7 +189,7 @@ impl IDb for SledDb {
}
});
match res {
- Ok(()) => Ok(()),
+ Ok(on_commit) => Ok(on_commit),
Err(TransactionError::Abort(())) => Err(TxError::Abort(())),
Err(TransactionError::Storage(s)) => Err(TxError::Db(s.into())),
}