some more fixes to allow sled to work
This commit is contained in:
@@ -447,6 +447,7 @@ impl Database {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sqlite")]
|
||||||
pub fn flush_wal(&self) -> Result<()> {
|
pub fn flush_wal(&self) -> Result<()> {
|
||||||
self._db.flush_wal()
|
self._db.flush_wal()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ impl DatabaseEngine for SledEngine {
|
|||||||
fn open_tree(self: &Arc<Self>, name: &'static str) -> Result<Arc<dyn Tree>> {
|
fn open_tree(self: &Arc<Self>, name: &'static str) -> Result<Arc<dyn Tree>> {
|
||||||
Ok(Arc::new(SledEngineTree(self.0.open_tree(name)?)))
|
Ok(Arc::new(SledEngineTree(self.0.open_tree(name)?)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn flush(self: &Arc<Self>) -> Result<()> {
|
||||||
|
Ok(()) // noop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tree for SledEngineTree {
|
impl Tree for SledEngineTree {
|
||||||
@@ -40,7 +44,7 @@ impl Tree for SledEngineTree {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + Send + Sync + 'a> {
|
fn iter<'a>(&'a self) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + Send + 'a> {
|
||||||
Box::new(
|
Box::new(
|
||||||
self.0
|
self.0
|
||||||
.iter()
|
.iter()
|
||||||
@@ -58,7 +62,7 @@ impl Tree for SledEngineTree {
|
|||||||
&self,
|
&self,
|
||||||
from: &[u8],
|
from: &[u8],
|
||||||
backwards: bool,
|
backwards: bool,
|
||||||
) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)>> {
|
) -> Box<dyn Iterator<Item = (Vec<u8>, Vec<u8>)> + Send> {
|
||||||
let iter = if backwards {
|
let iter = if backwards {
|
||||||
self.0.range(..from)
|
self.0.range(..from)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-8
@@ -12,10 +12,7 @@ mod pdu;
|
|||||||
mod ruma_wrapper;
|
mod ruma_wrapper;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
use std::{
|
use std::sync::Arc;
|
||||||
sync::{Arc, Weak},
|
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
|
||||||
|
|
||||||
use database::Config;
|
use database::Config;
|
||||||
pub use database::Database;
|
pub use database::Database;
|
||||||
@@ -33,10 +30,7 @@ use rocket::{
|
|||||||
},
|
},
|
||||||
routes, Request,
|
routes, Request,
|
||||||
};
|
};
|
||||||
use tokio::{
|
use tokio::sync::RwLock;
|
||||||
sync::RwLock,
|
|
||||||
time::{interval, timeout},
|
|
||||||
};
|
|
||||||
use tracing::span;
|
use tracing::span;
|
||||||
use tracing_subscriber::{prelude::*, Registry};
|
use tracing_subscriber::{prelude::*, Registry};
|
||||||
|
|
||||||
@@ -208,7 +202,15 @@ async fn main() {
|
|||||||
.await
|
.await
|
||||||
.expect("config is valid");
|
.expect("config is valid");
|
||||||
|
|
||||||
|
#[cfg(feature = "sqlite")]
|
||||||
{
|
{
|
||||||
|
use tokio::time::{interval, timeout};
|
||||||
|
|
||||||
|
use std::{
|
||||||
|
sync::Weak,
|
||||||
|
time::{Duration, Instant},
|
||||||
|
};
|
||||||
|
|
||||||
let weak: Weak<RwLock<Database>> = Arc::downgrade(&db);
|
let weak: Weak<RwLock<Database>> = Arc::downgrade(&db);
|
||||||
|
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
|
|||||||
Reference in New Issue
Block a user