Initial commit
This commit is contained in:
commit
f1e6c68aac
31 changed files with 3297 additions and 0 deletions
24
src/http/novels/pull_next.rs
Normal file
24
src/http/novels/pull_next.rs
Normal 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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue