[refactor]: remove redis code

This commit is contained in:
April John 2024-04-16 17:53:24 +00:00 committed by GitHub
parent 10495a070c
commit f3e010a321
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 7 deletions

View file

@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
pub type DatabaseHandle = Arc<Database>; pub type DatabaseHandle = Arc<Database>;
/// Our "database" which contains all known users (local and federated) /// Our "database" which contains all known users (local and federated)
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug)]
pub struct Database { pub struct Database {
pub users: Mutex<Vec<DbUser>>, pub users: Mutex<Vec<DbUser>>,
} }

View file

@ -24,7 +24,7 @@ mod http;
mod objects; mod objects;
mod utils; mod utils;
#[derive(Debug, Clone, Serialize, Deserialize, FromRedisValue, ToRedisArgs)] #[derive(Debug, Clone)]
struct State { struct State {
database: Arc<Database>, database: Arc<Database>,
} }
@ -87,9 +87,9 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
users: Mutex::new(vec![local_user]), users: Mutex::new(vec![local_user]),
}); });
let state: State = con.get("ap-layer-db").await.unwrap_or(State { let state: State = State {
database: new_database, database: new_database,
}); };
let data = FederationConfig::builder() let data = FederationConfig::builder()
.domain(env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set")) .domain(env::var("FEDERATED_DOMAIN").expect("FEDERATED_DOMAIN must be set"))
@ -144,8 +144,7 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
} }
} }
info!("memory-saving 'db' in redis.."); info!("Main thread shutdown..");
con.set("ap-layer-db", &state).await?;
Ok(()) Ok(())
} }

View file

@ -12,7 +12,7 @@ use serde::{Deserialize, Serialize};
use std::fmt::Debug; use std::fmt::Debug;
use url::Url; use url::Url;
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone)]
pub struct DbUser { pub struct DbUser {
pub name: String, pub name: String,
pub ap_id: ObjectId<DbUser>, pub ap_id: ObjectId<DbUser>,