mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 19:12:56 +01:00
Do not block on sink drop for FramedTransport
This commit is contained in:
parent
205cac82ce
commit
27baf03f64
@ -81,7 +81,7 @@ impl<S, R> ActixCompat<S, R> {
|
|||||||
|
|
||||||
/// Extension trait for wrapping a `tower_service::Service` instance for use as
|
/// Extension trait for wrapping a `tower_service::Service` instance for use as
|
||||||
/// an `actix_service::Service`.
|
/// an `actix_service::Service`.
|
||||||
pub trait TowerServiceExt<R> : TowerService<R> + Sized {
|
pub trait TowerServiceExt<R>: TowerService<R> + Sized {
|
||||||
/// Wraps a `tower_service::Service` in a compatibility wrapper.
|
/// Wraps a `tower_service::Service` in a compatibility wrapper.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
@ -167,16 +167,13 @@ pub trait TowerServiceExt<R> : TowerService<R> + Sized {
|
|||||||
fn wrap_with_actix_middleware<F, U>(self, f: F) -> TowerCompat<U>
|
fn wrap_with_actix_middleware<F, U>(self, f: F) -> TowerCompat<U>
|
||||||
where
|
where
|
||||||
F: FnOnce(ActixCompat<Self, R>) -> U,
|
F: FnOnce(ActixCompat<Self, R>) -> U,
|
||||||
U: ActixService<Request = R>
|
U: ActixService<Request = R>,
|
||||||
{
|
{
|
||||||
f(self.into_actix_service()).into_tower_service()
|
f(self.into_actix_service()).into_tower_service()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, R> TowerServiceExt<R> for S
|
impl<S, R> TowerServiceExt<R> for S where S: TowerService<R> + Sized {}
|
||||||
where
|
|
||||||
S: TowerService<R> + Sized
|
|
||||||
{}
|
|
||||||
|
|
||||||
impl<S, R> ActixService for ActixCompat<S, R>
|
impl<S, R> ActixService for ActixCompat<S, R>
|
||||||
where
|
where
|
||||||
@ -207,9 +204,7 @@ pub struct TowerCompat<S> {
|
|||||||
impl<S> TowerCompat<S> {
|
impl<S> TowerCompat<S> {
|
||||||
/// Wraps an `actix_service::Service` in a compatibility wrapper.
|
/// Wraps an `actix_service::Service` in a compatibility wrapper.
|
||||||
pub fn new(inner: S) -> Self {
|
pub fn new(inner: S) -> Self {
|
||||||
TowerCompat {
|
TowerCompat { inner }
|
||||||
inner,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,16 +297,13 @@ pub trait ActixServiceExt: ActixService + Sized {
|
|||||||
fn wrap_with_tower_middleware<F, U>(self, f: F) -> ActixCompat<U, Self::Request>
|
fn wrap_with_tower_middleware<F, U>(self, f: F) -> ActixCompat<U, Self::Request>
|
||||||
where
|
where
|
||||||
F: FnOnce(TowerCompat<Self>) -> U,
|
F: FnOnce(TowerCompat<Self>) -> U,
|
||||||
U: TowerService<Self::Request>
|
U: TowerService<Self::Request>,
|
||||||
{
|
{
|
||||||
f(self.into_tower_service()).into_actix_service()
|
f(self.into_tower_service()).into_actix_service()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> ActixServiceExt for S
|
impl<S> ActixServiceExt for S where S: ActixService + Sized {}
|
||||||
where
|
|
||||||
S: ActixService + Sized
|
|
||||||
{}
|
|
||||||
|
|
||||||
impl<S> TowerService<S::Request> for TowerCompat<S>
|
impl<S> TowerService<S::Request> for TowerCompat<S>
|
||||||
where
|
where
|
||||||
@ -335,10 +327,9 @@ mod tests {
|
|||||||
mod tower_service_into_actix_service {
|
mod tower_service_into_actix_service {
|
||||||
use crate::TowerServiceExt;
|
use crate::TowerServiceExt;
|
||||||
use actix_service::{Service as ActixService, ServiceExt, Transform};
|
use actix_service::{Service as ActixService, ServiceExt, Transform};
|
||||||
use futures::{future::FutureResult, Async, Poll, Future};
|
use futures::{future::FutureResult, Async, Future, Poll};
|
||||||
use tower_service::Service as TowerService;
|
use tower_service::Service as TowerService;
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_service_returns_4() {
|
fn random_service_returns_4() {
|
||||||
let mut s = RandomService.into_actix_service();
|
let mut s = RandomService.into_actix_service();
|
||||||
@ -397,7 +388,10 @@ mod tests {
|
|||||||
fn random_service_can_be_transformed_to_do_math() {
|
fn random_service_can_be_transformed_to_do_math() {
|
||||||
let transform = DoMath;
|
let transform = DoMath;
|
||||||
|
|
||||||
let mut s = transform.new_transform(RandomService.into_actix_service()).wait().unwrap();
|
let mut s = transform
|
||||||
|
.new_transform(RandomService.into_actix_service())
|
||||||
|
.wait()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
||||||
|
|
||||||
@ -477,10 +471,9 @@ mod tests {
|
|||||||
mod actix_service_into_tower_service {
|
mod actix_service_into_tower_service {
|
||||||
use crate::{ActixServiceExt, TowerServiceExt};
|
use crate::{ActixServiceExt, TowerServiceExt};
|
||||||
use actix_service::{Service as ActixService, ServiceExt};
|
use actix_service::{Service as ActixService, ServiceExt};
|
||||||
use futures::{future::FutureResult, Async, Poll, Future};
|
use futures::{future::FutureResult, Async, Future, Poll};
|
||||||
use tower_service::Service as TowerService;
|
use tower_service::Service as TowerService;
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_service_returns_4() {
|
fn random_service_returns_4() {
|
||||||
let mut s = RandomService.into_tower_service();
|
let mut s = RandomService.into_tower_service();
|
||||||
@ -492,7 +485,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_service_can_use_tower_middleware() {
|
fn random_service_can_use_tower_middleware() {
|
||||||
let mut s = AddOneService::wrap(RandomService.into_tower_service()).into_actix_service();
|
let mut s =
|
||||||
|
AddOneService::wrap(RandomService.into_tower_service()).into_actix_service();
|
||||||
|
|
||||||
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
||||||
|
|
||||||
@ -501,7 +495,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn do_math_service_can_use_tower_middleware() {
|
fn do_math_service_can_use_tower_middleware() {
|
||||||
let mut s = AddOneService::wrap(DoMathService.into_tower_service()).into_actix_service();
|
let mut s =
|
||||||
|
AddOneService::wrap(DoMathService.into_tower_service()).into_actix_service();
|
||||||
|
|
||||||
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
assert_eq!(Ok(Async::Ready(())), s.poll_ready());
|
||||||
|
|
||||||
@ -537,14 +532,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct AddOneService<S> {
|
struct AddOneService<S> {
|
||||||
inner: S
|
inner: S,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S> AddOneService<S> {
|
impl<S> AddOneService<S> {
|
||||||
fn wrap(inner: S) -> Self {
|
fn wrap(inner: S) -> Self {
|
||||||
AddOneService {
|
AddOneService { inner }
|
||||||
inner,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,8 +555,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, req: R) -> Self::Future {
|
fn call(&mut self, req: R) -> Self::Future {
|
||||||
let fut = self.inner.call(req)
|
let fut = self.inner.call(req).map(|x| x + 1);
|
||||||
.map(|x| x + 1);
|
|
||||||
|
|
||||||
Box::new(fut)
|
Box::new(fut)
|
||||||
}
|
}
|
||||||
@ -583,5 +575,6 @@ mod tests {
|
|||||||
fn call(&mut self, req: Self::Request) -> Self::Future {
|
fn call(&mut self, req: Self::Request) -> Self::Future {
|
||||||
futures::finished(req * 17)
|
futures::finished(req * 17)
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,13 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
##[0.4.1] - 2019-05-15
|
## [0.4.2] - 2019-06-26
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Do not block on sink drop for FramedTransport
|
||||||
|
|
||||||
|
|
||||||
|
## [0.4.1] - 2019-05-15
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-utils"
|
name = "actix-utils"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix utils - various actix net related services"
|
description = "Actix utils - various actix net related services"
|
||||||
keywords = ["network", "framework", "async", "futures"]
|
keywords = ["network", "framework", "async", "futures"]
|
||||||
@ -18,8 +18,8 @@ name = "actix_utils"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "0.4.0"
|
actix-service = "0.4.1"
|
||||||
actix-codec = "0.1.1"
|
actix-codec = "0.1.2"
|
||||||
bytes = "0.4"
|
bytes = "0.4"
|
||||||
either = "1.5.2"
|
either = "1.5.2"
|
||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
|
@ -187,10 +187,12 @@ where
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Ok(Async::Ready(None)) => {
|
Ok(Async::Ready(None)) => {
|
||||||
|
rx_done = true;
|
||||||
let _ = self.rx.take();
|
let _ = self.rx.take();
|
||||||
}
|
}
|
||||||
Ok(Async::NotReady) => rx_done = true,
|
Ok(Async::NotReady) => rx_done = true,
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
rx_done = true;
|
||||||
let _ = self.rx.take();
|
let _ = self.rx.take();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user