From dc5f1f41fd4751b3de4f13a44c74ce090d0abc8e Mon Sep 17 00:00:00 2001 From: Jonathan de Jong Date: Wed, 7 Jul 2021 14:04:11 +0200 Subject: [PATCH] some more fixes to allow sled to work --- src/database.rs | 1 + src/database/abstraction/sled.rs | 8 ++++++-- src/main.rs | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/database.rs b/src/database.rs index 99866511..bd582990 100644 --- a/src/database.rs +++ b/src/database.rs @@ -447,6 +447,7 @@ impl Database { res } + #[cfg(feature = "sqlite")] pub fn flush_wal(&self) -> Result<()> { self._db.flush_wal() } diff --git a/src/database/abstraction/sled.rs b/src/database/abstraction/sled.rs index 2f3fb346..557e8a0e 100644 --- a/src/database/abstraction/sled.rs +++ b/src/database/abstraction/sled.rs @@ -23,6 +23,10 @@ impl DatabaseEngine for SledEngine { fn open_tree(self: &Arc, name: &'static str) -> Result> { Ok(Arc::new(SledEngineTree(self.0.open_tree(name)?))) } + + fn flush(self: &Arc) -> Result<()> { + Ok(()) // noop + } } impl Tree for SledEngineTree { @@ -40,7 +44,7 @@ impl Tree for SledEngineTree { Ok(()) } - fn iter<'a>(&'a self) -> Box, Vec)> + Send + Sync + 'a> { + fn iter<'a>(&'a self) -> Box, Vec)> + Send + 'a> { Box::new( self.0 .iter() @@ -58,7 +62,7 @@ impl Tree for SledEngineTree { &self, from: &[u8], backwards: bool, - ) -> Box, Vec)>> { + ) -> Box, Vec)> + Send> { let iter = if backwards { self.0.range(..from) } else { diff --git a/src/main.rs b/src/main.rs index 55987285..5c5ea847 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,10 +12,7 @@ mod pdu; mod ruma_wrapper; mod utils; -use std::{ - sync::{Arc, Weak}, - time::{Duration, Instant}, -}; +use std::sync::Arc; use database::Config; pub use database::Database; @@ -33,10 +30,7 @@ use rocket::{ }, routes, Request, }; -use tokio::{ - sync::RwLock, - time::{interval, timeout}, -}; +use tokio::sync::RwLock; use tracing::span; use tracing_subscriber::{prelude::*, Registry}; @@ -208,7 +202,15 @@ async fn main() { .await .expect("config is valid"); + #[cfg(feature = "sqlite")] { + use tokio::time::{interval, timeout}; + + use std::{ + sync::Weak, + time::{Duration, Instant}, + }; + let weak: Weak> = Arc::downgrade(&db); tokio::spawn(async {