mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 14:48:19 +01:00
[refactor]: remove redis code
This commit is contained in:
parent
10495a070c
commit
f3e010a321
|
|
@ -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>>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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>,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue