convert plume-models to all async
where sensible! note that State has no asynchronous work to do, so wrapping it up in async makes no sense.
This commit is contained in:
parent
ce119ffe50
commit
59e5c49aa8
@ -28,7 +28,7 @@ impl<'a, 'r> FromRequestAsync<'a, 'r> for DbConn {
|
||||
Box::pin(async move {
|
||||
match DbConn::from_request(request).await {
|
||||
Outcome::Success(a) => return Outcome::Success(a),
|
||||
Outcome::Failure(_) => return Outcome::Failure((Status::ServiceUnavailable, ())),
|
||||
_ => return Outcome::Failure((Status::ServiceUnavailable, ())),
|
||||
};
|
||||
})
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ pub use self::module::PlumeRocket;
|
||||
mod module {
|
||||
use crate::{db_conn::DbConn, search, users};
|
||||
use rocket::{
|
||||
request::{self, FlashMessage, FromRequest, FromRequestAsync, Request},
|
||||
request::{self, FlashMessage, FromRequestAsync, Request},
|
||||
Outcome, State,
|
||||
};
|
||||
use scheduled_thread_pool::ScheduledThreadPool;
|
||||
@ -28,13 +28,13 @@ mod module {
|
||||
let conn = try_outcome!(DbConn::from_request(request).await);
|
||||
let intl = try_outcome!(rocket_i18n::I18n::from_request(request).await);
|
||||
let user = try_outcome!(users::User::from_request(request).await);
|
||||
let worker = request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>()?;
|
||||
let searcher = request.guard::<'_, State<'_, Arc<search::Searcher>>>()?;
|
||||
let worker = try_outcome!(request.guard::<'_, State<'_, Arc<ScheduledThreadPool>>>());
|
||||
let searcher = try_outcome!(request.guard::<'_, State<'_, Arc<search::Searcher>>>());
|
||||
let flash_msg = request.guard::<FlashMessage<'_, '_>>().succeeded();
|
||||
Outcome::Success(PlumeRocket {
|
||||
conn,
|
||||
intl,
|
||||
user,
|
||||
user: Some(user),
|
||||
flash_msg: flash_msg.map(|f| (f.name().into(), f.msg().into())),
|
||||
worker: worker.clone(),
|
||||
searcher: searcher.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user