diff options
author | Alex Auvolat <alex@adnab.me> | 2022-02-25 20:42:56 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-03-14 11:41:20 +0100 |
commit | fe62d01b7efd878d291d9830f530c769eeeb62ec (patch) | |
tree | 1a04828b9d00e0757a57ec3eb55732f79adfecc4 /src/util | |
parent | bfb4353df50f31fc3b00a9833c09b8de16b471fc (diff) | |
download | garage-fe62d01b7efd878d291d9830f530c769eeeb62ec.tar.gz garage-fe62d01b7efd878d291d9830f530c769eeeb62ec.zip |
Implement exponential backoff for resync retriesfeature/opentelemetrybug/resync-exponential-backoff
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/sled_counter.rs | 8 |
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 { |