aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-25 20:42:56 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-14 11:41:20 +0100
commitfe62d01b7efd878d291d9830f530c769eeeb62ec (patch)
tree1a04828b9d00e0757a57ec3eb55732f79adfecc4 /src/util
parentbfb4353df50f31fc3b00a9833c09b8de16b471fc (diff)
downloadgarage-feature/opentelemetry.tar.gz
garage-feature/opentelemetry.zip
Implement exponential backoff for resync retriesfeature/opentelemetrybug/resync-exponential-backoff
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sled_counter.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/sled_counter.rs b/src/util/sled_counter.rs
index 8af04f50..bc54cea0 100644
--- a/src/util/sled_counter.rs
+++ b/src/util/sled_counter.rs
@@ -52,6 +52,14 @@ impl SledCountedTree {
res
}
+ pub fn remove<K: AsRef<[u8]>>(&self, key: K) -> Result<Option<IVec>> {
+ let res = self.0.tree.remove(key);
+ if matches!(res, Ok(Some(_))) {
+ self.0.len.fetch_sub(1, Ordering::Relaxed);
+ }
+ res
+ }
+
pub fn pop_min(&self) -> Result<Option<(IVec, IVec)>> {
let res = self.0.tree.pop_min();
if let Ok(Some(_)) = &res {