mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 16:52:58 +01:00
depend on git repo
This commit is contained in:
parent
5b8446105f
commit
406088524e
@ -18,8 +18,7 @@ name = "actix_utils"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
#actix-service = "0.2.0"
|
||||
actix-service = { git = "https://github.com/actix/actix-net.git" }
|
||||
actix-service = "0.2.0"
|
||||
actix-codec = "0.1.0"
|
||||
bytes = "0.4"
|
||||
futures = "0.1"
|
||||
@ -28,4 +27,7 @@ tokio-current-thread = "0.1"
|
||||
log = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "0.1"
|
||||
actix-rt = "0.1"
|
||||
|
||||
[patch.crates-io]
|
||||
actix-service = { git = "https://github.com/actix/actix-net.git" }
|
||||
|
@ -3,6 +3,7 @@
|
||||
//! If the response does not complete within the specified timeout, the response
|
||||
//! will be aborted.
|
||||
use std::fmt;
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Duration;
|
||||
|
||||
use actix_service::{NewTransform, Service, Transform};
|
||||
@ -12,8 +13,9 @@ use tokio_timer::{clock, Delay};
|
||||
|
||||
/// Applies a timeout to requests.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Timeout {
|
||||
pub struct Timeout<E = ()> {
|
||||
timeout: Duration,
|
||||
_t: PhantomData<E>,
|
||||
}
|
||||
|
||||
/// Timeout error
|
||||
@ -54,20 +56,23 @@ impl<E: PartialEq> PartialEq for TimeoutError<E> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Timeout {
|
||||
impl<E> Timeout<E> {
|
||||
pub fn new(timeout: Duration) -> Self {
|
||||
Timeout { timeout }
|
||||
Timeout {
|
||||
timeout,
|
||||
_t: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> NewTransform<S> for Timeout
|
||||
impl<S, E> NewTransform<S> for Timeout<E>
|
||||
where
|
||||
S: Service,
|
||||
{
|
||||
type Request = S::Request;
|
||||
type Response = S::Response;
|
||||
type Error = TimeoutError<S::Error>;
|
||||
type InitError = ();
|
||||
type InitError = E;
|
||||
type Transform = TimeoutService;
|
||||
type Future = FutureResult<Self::Transform, Self::InitError>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user