mirror of
https://github.com/fafhrd91/actix-net
synced 2025-03-20 12:35:18 +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"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
#actix-service = "0.2.0"
|
actix-service = "0.2.0"
|
||||||
actix-service = { git = "https://github.com/actix/actix-net.git" }
|
|
||||||
actix-codec = "0.1.0"
|
actix-codec = "0.1.0"
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
@ -28,4 +27,7 @@ tokio-current-thread = "0.1"
|
|||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[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
|
//! If the response does not complete within the specified timeout, the response
|
||||||
//! will be aborted.
|
//! will be aborted.
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::marker::PhantomData;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix_service::{NewTransform, Service, Transform};
|
use actix_service::{NewTransform, Service, Transform};
|
||||||
@ -12,8 +13,9 @@ use tokio_timer::{clock, Delay};
|
|||||||
|
|
||||||
/// Applies a timeout to requests.
|
/// Applies a timeout to requests.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Timeout {
|
pub struct Timeout<E = ()> {
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
|
_t: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Timeout error
|
/// 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 {
|
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
|
where
|
||||||
S: Service,
|
S: Service,
|
||||||
{
|
{
|
||||||
type Request = S::Request;
|
type Request = S::Request;
|
||||||
type Response = S::Response;
|
type Response = S::Response;
|
||||||
type Error = TimeoutError<S::Error>;
|
type Error = TimeoutError<S::Error>;
|
||||||
type InitError = ();
|
type InitError = E;
|
||||||
type Transform = TimeoutService;
|
type Transform = TimeoutService;
|
||||||
type Future = FutureResult<Self::Transform, Self::InitError>;
|
type Future = FutureResult<Self::Transform, Self::InitError>;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user