Fuzz Bucket CRDT (#1442)

Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1442
Reviewed-by: Alex <lx@deuxfleurs.fr>
This commit is contained in:
Arthur Carcano
2026-05-06 18:55:47 +00:00
committed by Alex
parent 57ceed38f3
commit 0da317e3d5
9 changed files with 73 additions and 0 deletions
+1
View File
@@ -4,6 +4,7 @@ use crate::crdt::crdt::*;
/// Deletable object (once deleted, cannot go back)
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum Deletable<T> {
Present(T),
Deleted,
+1
View File
@@ -38,6 +38,7 @@ use crate::crdt::crdt::*;
/// This scheme is used by AWS S3 or Soundcloud and often without knowing
/// in enterprise when reconciliating databases with ad-hoc scripts.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub struct Lww<T> {
ts: u64,
v: T,
+16
View File
@@ -200,3 +200,19 @@ where
Self::new()
}
}
#[cfg(feature = "arbitrary")]
impl<'a, K, V> arbitrary::Arbitrary<'a> for LwwMap<K, V>
where
K: arbitrary::Arbitrary<'a> + Clone + Ord,
V: arbitrary::Arbitrary<'a> + Clone + Crdt,
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let map: std::collections::BTreeMap<K, (u64, V)> = arbitrary::Arbitrary::arbitrary(u)?;
let mut result = LwwMap::new();
for (k, (ts, v)) in map {
result.merge_raw(&k, ts, &v);
}
Ok(result)
}
}
+12
View File
@@ -123,3 +123,15 @@ where
Self { vals }
}
}
#[cfg(feature = "arbitrary")]
impl<'a, K, V> arbitrary::Arbitrary<'a> for Map<K, V>
where
K: arbitrary::Arbitrary<'a> + Clone + Ord,
V: arbitrary::Arbitrary<'a> + Clone + Crdt,
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let map: std::collections::BTreeMap<K, V> = arbitrary::Arbitrary::arbitrary(u)?;
Ok(map.into_iter().collect())
}
}