Initial commit

This commit is contained in:
Aleksandr 2024-11-17 14:58:34 +03:00
commit f1e6c68aac
31 changed files with 3297 additions and 0 deletions

View file

@ -0,0 +1,24 @@
use std::time::Duration;
use crate::{
result::ApiResult,
state::{Router, State},
};
use axum::routing::get;
use tokio::time;
async fn pull_next(state: State) -> ApiResult<Option<String>> {
let rx = state.app.write().subs.subscribe();
let Ok(Ok(r)) = time::timeout(Duration::from_secs(12 * 60 * 60), rx).await else {
tracing::debug!("timed out for subscription");
return Ok(None.into());
};
Ok(Some(r).into())
}
pub fn make() -> Router {
Router::new().route("/", get(pull_next))
}