24 lines
530 B
Rust
24 lines
530 B
Rust
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))
|
|
}
|