diff options
author | Alex Auvolat <alex@adnab.me> | 2023-01-03 15:08:37 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-01-03 15:08:37 +0100 |
commit | 426d8784dac0e39879af52d980887d3692fc907c (patch) | |
tree | a5bf205a5e8cd013e98cc88fe57aeaeebb86e30b /src/model/index_counter.rs | |
parent | a81200d345e23b93b8f6e1d879b6b14efbdfb2bb (diff) | |
download | garage-426d8784dac0e39879af52d980887d3692fc907c.tar.gz garage-426d8784dac0e39879af52d980887d3692fc907c.zip |
cleanup
Diffstat (limited to 'src/model/index_counter.rs')
-rw-r--r-- | src/model/index_counter.rs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/model/index_counter.rs b/src/model/index_counter.rs index c3ed29c7..3cd3083a 100644 --- a/src/model/index_counter.rs +++ b/src/model/index_counter.rs @@ -31,7 +31,12 @@ pub trait CountedItem: Clone + PartialEq + Send + Sync + 'static { } mod v08 { - use super::*; + use super::CountedItem; + use garage_util::data::Uuid; + use serde::{Deserialize, Serialize}; + use std::collections::BTreeMap; + + // ---- Global part (the table everyone queries) ---- /// A counter entry in the global table #[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] @@ -48,6 +53,17 @@ mod v08 { } impl<T: CountedItem> garage_util::migrate::InitialFormat for CounterEntry<T> {} + + // ---- Local part (the counter we maintain transactionnaly on each node) ---- + + #[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] + pub(super) struct LocalCounterEntry<T: CountedItem> { + pub(super) pk: T::CP, + pub(super) sk: T::CS, + pub(super) values: BTreeMap<String, (u64, i64)>, + } + + impl<T: CountedItem> garage_util::migrate::InitialFormat for LocalCounterEntry<T> {} } pub use v08::*; @@ -358,15 +374,6 @@ impl<T: CountedItem> IndexCounter<T> { // ---- -#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)] -struct LocalCounterEntry<T: CountedItem> { - pk: T::CP, - sk: T::CS, - values: BTreeMap<String, (u64, i64)>, -} - -impl<T: CountedItem> garage_util::migrate::InitialFormat for LocalCounterEntry<T> {} - impl<T: CountedItem> LocalCounterEntry<T> { fn into_counter_entry(self, this_node: Uuid) -> CounterEntry<T> { CounterEntry { |