mirror of
https://github.com/nullishamy/ferri.git
synced 2025-06-28 00:54:17 +00:00
feat: queue infra
This commit is contained in:
parent
2270324711
commit
4b88100373
4 changed files with 77 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
|||
use main::ap::http::HttpClient;
|
||||
use rocket::{State, get, response::status};
|
||||
use rocket_db_pools::Connection;
|
||||
use main::ap;
|
||||
use crate::OutboundQueue;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
|
@ -84,7 +86,9 @@ pub async fn resolve_user(acct: &str, host: &str) -> types::Person {
|
|||
}
|
||||
|
||||
#[get("/test")]
|
||||
pub async fn test(http: &State<HttpClient>) -> &'static str {
|
||||
pub async fn test(http: &State<HttpClient>, outbound: &State<OutboundQueue>) -> &'static str {
|
||||
outbound.0.send(ap::QueueMessage::Heartbeat);
|
||||
|
||||
let user = resolve_user("amy@fedi.amy.mov", "fedi.amy.mov").await;
|
||||
|
||||
let post = activity::CreateActivity {
|
||||
|
|
|
@ -6,6 +6,8 @@ use endpoints::{
|
|||
use tracing::Level;
|
||||
use tracing_subscriber::fmt;
|
||||
|
||||
use main::ap;
|
||||
|
||||
use main::ap::http;
|
||||
use main::config::Config;
|
||||
use rocket::{
|
||||
|
@ -88,7 +90,8 @@ impl<'a> FromRequest<'a> for AuthenticatedUser {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub struct OutboundQueue(pub ap::QueueHandle);
|
||||
pub struct InboundQueue(pub ap::QueueHandle);
|
||||
|
||||
pub fn launch(cfg: Config) -> Rocket<Build> {
|
||||
let format = fmt::format()
|
||||
|
@ -104,11 +107,19 @@ pub fn launch(cfg: Config) -> Rocket<Build> {
|
|||
.event_format(format)
|
||||
.with_writer(std::io::stdout)
|
||||
.init();
|
||||
|
||||
|
||||
let outbound = ap::RequestQueue::new("outbound");
|
||||
let outbound_handle = outbound.spawn();
|
||||
|
||||
let inbound = ap::RequestQueue::new("inbound");
|
||||
let inbound_handle = inbound.spawn();
|
||||
|
||||
let http_client = http::HttpClient::new();
|
||||
build()
|
||||
.manage(cfg)
|
||||
.manage(http_client)
|
||||
.manage(OutboundQueue(outbound_handle))
|
||||
.manage(InboundQueue(inbound_handle))
|
||||
.attach(Db::init())
|
||||
.attach(cors::CORS)
|
||||
.mount("/assets", rocket::fs::FileServer::from("./assets"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue