diff --git a/moots-1-simple/src/lib.rs b/moots-1-simple/src/lib.rs new file mode 100644 index 0000000..ca4380a --- /dev/null +++ b/moots-1-simple/src/lib.rs @@ -0,0 +1,8 @@ +use std::sync::Arc; + +pub mod serve; +pub mod sync; + +pub struct Moots { + pub db: Arc, +} diff --git a/moots-1-simple/src/serve.rs b/moots-1-simple/src/serve.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/moots-1-simple/src/serve.rs @@ -0,0 +1 @@ + diff --git a/moots-1-simple/src/sync.rs b/moots-1-simple/src/sync.rs new file mode 100644 index 0000000..818ba66 --- /dev/null +++ b/moots-1-simple/src/sync.rs @@ -0,0 +1,45 @@ +use hubble_sync::{ + AccountStatus, AppResult, Commit, RepoContext, ResyncData, SimpleSyncConsumer, StorageEngine, +}; +use hubble_sync_rocksdb::RocksEngine; + +use crate::Moots; + +impl SimpleSyncConsumer for Moots { + type Engine = RocksEngine; + + fn apply_commit( + &self, + commit: Commit, + ctx: &RepoContext, + batch: &mut ::Batch, + ) -> AppResult { + Ok(()) + } + + fn apply_resync( + &self, + data: &mut ResyncData, + ctx: &RepoContext, + batch: &mut ::Batch, + ) -> AppResult { + Ok(()) + } + + fn apply_status( + &self, + prev: &AccountStatus, + ctx: &RepoContext, + batch: &mut ::Batch, + ) -> AppResult { + use AccountStatus as S; + + let deleting = (*prev != S::Deleted) && (ctx.status() == S::Deleted); + if deleting { + // let records = self.db.cf_handle("records").expect("records cf"); + // batch.inner_mut().delete_range_cf(&records, from, to); + } + + Ok(()) + } +}