1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

export AcceptorTimeout

This commit is contained in:
Nikolay Kim 2018-10-02 19:12:08 -07:00
parent 1f68ce8541
commit bbcd618304
3 changed files with 13 additions and 6 deletions

View File

@ -172,10 +172,11 @@ where
}
}
#[doc(hidden)]
/// Acceptor timeout middleware
///
/// Applies timeout to request prcoessing.
pub(crate) struct AcceptorTimeout<T> {
pub struct AcceptorTimeout<T> {
inner: T,
timeout: Duration,
}
@ -206,7 +207,7 @@ impl<T: NewService> NewService for AcceptorTimeout<T> {
}
#[doc(hidden)]
pub(crate) struct AcceptorTimeoutFut<T: NewService> {
pub struct AcceptorTimeoutFut<T: NewService> {
fut: T::Future,
timeout: Duration,
}
@ -224,10 +225,11 @@ impl<T: NewService> Future for AcceptorTimeoutFut<T> {
}
}
#[doc(hidden)]
/// Acceptor timeout service
///
/// Applies timeout to request prcoessing.
pub(crate) struct AcceptorTimeoutService<T> {
pub struct AcceptorTimeoutService<T> {
inner: T,
timeout: Duration,
}
@ -250,10 +252,12 @@ impl<T: Service> Service for AcceptorTimeoutService<T> {
}
}
pub(crate) struct AcceptorTimeoutResponse<T: Service> {
#[doc(hidden)]
pub struct AcceptorTimeoutResponse<T: Service> {
fut: T::Future,
sleep: Delay,
}
impl<T: Service> Future for AcceptorTimeoutResponse<T> {
type Item = T::Response;
type Error = AcceptorError<T::Error>;

View File

@ -145,6 +145,9 @@ pub use self::ssl::*;
pub use self::error::{AcceptorError, HttpDispatchError};
pub use self::settings::ServerSettings;
#[doc(hidden)]
pub use self::acceptor::AcceptorTimeout;
#[doc(hidden)]
pub use self::settings::{ServiceConfig, ServiceConfigBuilder};

View File

@ -282,7 +282,7 @@ impl<H: 'static> ServiceConfig<H> {
// periodic date update
let s = self.clone();
spawn(sleep(Duration::from_secs(1)).then(move |_| {
spawn(sleep(Duration::from_millis(500)).then(move |_| {
s.update_date();
future::ok(())
}));
@ -310,7 +310,7 @@ impl<H: 'static> ServiceConfig<H> {
// periodic date update
let s = self.clone();
spawn(sleep(Duration::from_secs(1)).then(move |_| {
spawn(sleep(Duration::from_millis(500)).then(move |_| {
s.update_date();
future::ok(())
}));