1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-30 17:44:34 +01:00

revert 1.0.3 changes

This commit is contained in:
Nikolay Kim 2020-01-15 13:24:38 -08:00
parent 5940731ef0
commit 3116db5168
5 changed files with 20 additions and 21 deletions

View File

@ -1,5 +1,11 @@
# Changes # Changes
## [1.0.4] - 2020-01-15
### Fixed
* Revert 1.0.3 change
## [1.0.3] - 2020-01-15 ## [1.0.3] - 2020-01-15
### Fixed ### Fixed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-service" name = "actix-service"
version = "1.0.3" version = "1.0.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix service" description = "Actix service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -13,7 +13,6 @@ edition = "2018"
[badges] [badges]
travis-ci = { repository = "actix/actix-service", branch = "master" } travis-ci = { repository = "actix/actix-service", branch = "master" }
appveyor = { repository = "actix/actix-net" }
codecov = { repository = "actix/actix-service", branch = "master", service = "github" } codecov = { repository = "actix/actix-service", branch = "master", service = "github" }
[lib] [lib]

View File

@ -9,7 +9,7 @@ use crate::cell::Cell;
/// of another service which completes successfully. /// of another service which completes successfully.
/// ///
/// This is created by the `ServiceExt::and_then` method. /// This is created by the `ServiceExt::and_then` method.
pub struct AndThenService<A, B>(Cell<(A, B)>); pub struct AndThenService<A, B>(Cell<A>, Cell<B>);
impl<A, B> AndThenService<A, B> { impl<A, B> AndThenService<A, B> {
/// Create new `AndThen` combinator /// Create new `AndThen` combinator
@ -18,13 +18,13 @@ impl<A, B> AndThenService<A, B> {
A: Service, A: Service,
B: Service<Request = A::Response, Error = A::Error>, B: Service<Request = A::Response, Error = A::Error>,
{ {
Self(Cell::new((a, b))) Self(Cell::new(a), Cell::new(b))
} }
} }
impl<A, B> Clone for AndThenService<A, B> { impl<A, B> Clone for AndThenService<A, B> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
AndThenService(self.0.clone()) AndThenService(self.0.clone(), self.1.clone())
} }
} }
@ -39,10 +39,8 @@ where
type Future = AndThenServiceResponse<A, B>; type Future = AndThenServiceResponse<A, B>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> { fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
let srv = self.0.get_mut(); let not_ready = { !self.0.get_mut().poll_ready(cx)?.is_ready() };
if !self.1.poll_ready(cx)?.is_ready() || not_ready {
let not_ready = !srv.0.poll_ready(cx)?.is_ready();
if !srv.1.poll_ready(cx)?.is_ready() || not_ready {
Poll::Pending Poll::Pending
} else { } else {
Poll::Ready(Ok(())) Poll::Ready(Ok(()))
@ -51,7 +49,7 @@ where
fn call(&mut self, req: A::Request) -> Self::Future { fn call(&mut self, req: A::Request) -> Self::Future {
AndThenServiceResponse { AndThenServiceResponse {
state: State::A(self.0.get_mut().0.call(req), Some(self.0.clone())), state: State::A(self.0.get_mut().call(req), Some(self.1.clone())),
} }
} }
} }
@ -72,7 +70,7 @@ where
A: Service, A: Service,
B: Service<Request = A::Response, Error = A::Error>, B: Service<Request = A::Response, Error = A::Error>,
{ {
A(#[pin] A::Future, Option<Cell<(A, B)>>), A(#[pin] A::Future, Option<Cell<B>>),
B(#[pin] B::Future), B(#[pin] B::Future),
Empty, Empty,
} }
@ -94,7 +92,7 @@ where
Poll::Ready(res) => { Poll::Ready(res) => {
let mut b = b.take().unwrap(); let mut b = b.take().unwrap();
this.state.set(State::Empty); // drop fut A this.state.set(State::Empty); // drop fut A
let fut = b.get_mut().1.call(res); let fut = b.get_mut().call(res);
this.state.set(State::B(fut)); this.state.set(State::B(fut));
self.poll(cx) self.poll(cx)
} }

View File

@ -50,7 +50,7 @@ impl<T: Service> Pipeline<T> {
where where
Self: Sized, Self: Sized,
F: IntoService<U>, F: IntoService<U>,
U: Service<Request = T::Response, Error = T::Error> + 'static, U: Service<Request = T::Response, Error = T::Error>,
{ {
Pipeline { Pipeline {
service: AndThenService::new(self.service, service.into_service()), service: AndThenService::new(self.service, service.into_service()),
@ -69,7 +69,7 @@ impl<T: Service> Pipeline<T> {
where where
Self: Sized, Self: Sized,
I: IntoService<U>, I: IntoService<U>,
U: Service + 'static, U: Service,
F: FnMut(T::Response, &mut U) -> Fut, F: FnMut(T::Response, &mut U) -> Fut,
Fut: Future<Output = Result<Res, Err>>, Fut: Future<Output = Result<Res, Err>>,
Err: From<T::Error> + From<U::Error>, Err: From<T::Error> + From<U::Error>,
@ -88,7 +88,7 @@ impl<T: Service> Pipeline<T> {
where where
Self: Sized, Self: Sized,
F: IntoService<U>, F: IntoService<U>,
U: Service<Request = Result<T::Response, T::Error>, Error = T::Error> + 'static, U: Service<Request = Result<T::Response, T::Error>, Error = T::Error>,
{ {
Pipeline { Pipeline {
service: ThenService::new(self.service, service.into_service()), service: ThenService::new(self.service, service.into_service()),
@ -179,7 +179,6 @@ impl<T: ServiceFactory> PipelineFactory<T> {
Error = T::Error, Error = T::Error,
InitError = T::InitError, InitError = T::InitError,
>, >,
U::Service: 'static,
{ {
PipelineFactory { PipelineFactory {
factory: AndThenServiceFactory::new(self.factory, factory.into_factory()), factory: AndThenServiceFactory::new(self.factory, factory.into_factory()),
@ -200,7 +199,6 @@ impl<T: ServiceFactory> PipelineFactory<T> {
T::Config: Clone, T::Config: Clone,
I: IntoServiceFactory<U>, I: IntoServiceFactory<U>,
U: ServiceFactory<Config = T::Config, InitError = T::InitError>, U: ServiceFactory<Config = T::Config, InitError = T::InitError>,
U::Service: 'static,
F: FnMut(T::Response, &mut U::Service) -> Fut + Clone, F: FnMut(T::Response, &mut U::Service) -> Fut + Clone,
Fut: Future<Output = Result<Res, Err>>, Fut: Future<Output = Result<Res, Err>>,
Err: From<T::Error> + From<U::Error>, Err: From<T::Error> + From<U::Error>,
@ -227,7 +225,6 @@ impl<T: ServiceFactory> PipelineFactory<T> {
Error = T::Error, Error = T::Error,
InitError = T::InitError, InitError = T::InitError,
>, >,
U::Service: 'static,
{ {
PipelineFactory { PipelineFactory {
factory: ThenServiceFactory::new(self.factory, factory.into_factory()), factory: ThenServiceFactory::new(self.factory, factory.into_factory()),

View File

@ -10,15 +10,14 @@ documentation = "https://docs.rs/actix-tracing/"
categories = ["network-programming", "asynchronous"] categories = ["network-programming", "asynchronous"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
edition = "2018" edition = "2018"
workspace = ".."
[lib] [lib]
name = "actix_tracing" name = "actix_tracing"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-service = "1.0" actix-service = "1.0.3"
futures-util = "0.3" futures-util = "0.3.1"
tracing = "0.1" tracing = "0.1"
tracing-futures = "0.2" tracing-futures = "0.2"