feat: swappable database backend

This commit is contained in:
Timo Kösters 2021-06-08 18:10:00 +02:00
parent 81715bd84d
commit d0ee823254
No known key found for this signature in database
GPG key ID: 24DA7517711A2BA4
47 changed files with 1434 additions and 981 deletions

View file

@ -1,10 +1,10 @@
use crate::Error;
use crate::{Database, Error};
use ruma::{
api::OutgoingResponse,
identifiers::{DeviceId, UserId},
Outgoing,
};
use std::ops::Deref;
use std::{ops::Deref, sync::Arc};
#[cfg(feature = "conduit_bin")]
use {
@ -51,7 +51,7 @@ where
async fn from_data(request: &'a Request<'_>, data: Data) -> data::Outcome<Self, Self::Error> {
let metadata = T::Incoming::METADATA;
let db = request
.guard::<State<'_, crate::Database>>()
.guard::<State<'_, Arc<Database>>>()
.await
.expect("database was loaded");
@ -75,6 +75,7 @@ where
)) = db
.appservice
.iter_all()
.unwrap()
.filter_map(|r| r.ok())
.find(|(_id, registration)| {
registration