From 871ca5e4ae2bdc22d1ea02701c2992fa8d04aed7 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 11 Feb 2021 21:44:22 +0000 Subject: [PATCH] stop claiming actor support --- README.md | 1 - actix-http/src/h1/dispatcher.rs | 10 +++++++ src/lib.rs | 27 ----------------- src/test.rs | 53 --------------------------------- 4 files changed, 10 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index ff375506..cc7c4cd5 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,6 @@ * SSL support using OpenSSL or Rustls * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) * Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html) -* Supports [Actix actor framework](https://github.com/actix/actix) * Runs on stable Rust 1.46+ ## Documentation diff --git a/actix-http/src/h1/dispatcher.rs b/actix-http/src/h1/dispatcher.rs index c4ccf72c..94bc5c44 100644 --- a/actix-http/src/h1/dispatcher.rs +++ b/actix-http/src/h1/dispatcher.rs @@ -356,6 +356,7 @@ where this.state.set(State::ServiceCall(task)); }; } + // handle error message. Some(DispatcherMessage::Error(res)) => { // send_response would update InnerDispatcher state to SendPayload or @@ -364,10 +365,12 @@ where self.as_mut() .send_response(res, ResponseBody::Other(Body::Empty))?; } + // return with upgrade request and poll it exclusively. Some(DispatcherMessage::Upgrade(req)) => { return Ok(PollResponse::Upgrade(req)); } + // all messages are dealt with. None => return Ok(PollResponse::DoNothing), }, @@ -377,12 +380,14 @@ where let (res, body) = res.into().replace_body(()); self.as_mut().send_response(res, body)?; } + // send service call error as response Poll::Ready(Err(e)) => { let res: Response = e.into().into(); let (res, body) = res.replace_body(()); self.as_mut().send_response(res, body.into_body())?; } + // service call pending and could be waiting for more chunk messages. // (pipeline message limit and/or payload can_read limit) Poll::Pending => { @@ -394,6 +399,7 @@ where // otherwise keep loop. } }, + StateProj::SendPayload(mut stream) => { // keep populate writer buffer until buffer size limit hit, // get blocked or finished. @@ -405,6 +411,7 @@ where &mut this.write_buf, )?; } + Poll::Ready(None) => { this.codec .encode(Message::Chunk(None), &mut this.write_buf)?; @@ -413,9 +420,11 @@ where this.state.set(State::None); continue 'res; } + Poll::Ready(Some(Err(e))) => { return Err(DispatchError::Service(e)) } + Poll::Pending => return Ok(PollResponse::DoNothing), } } @@ -423,6 +432,7 @@ where // return and try to write the whole buffer to io stream. return Ok(PollResponse::DrainWriteBuf); } + StateProj::ExpectCall(fut) => match fut.poll(cx) { // expect resolved. write continue to buffer and set InnerDispatcher state // to service call. diff --git a/src/lib.rs b/src/lib.rs index 7f096584..271efa0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,6 @@ //! * SSL support using OpenSSL or Rustls //! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/)) //! * Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html) -//! * Supports [Actix actor framework](https://github.com/actix/actix) //! * Runs on stable Rust 1.46+ //! //! ## Crate Features @@ -203,29 +202,3 @@ pub mod dev { } } } - -pub mod client { - //! Actix Web async HTTP client. - //! - //! ```rust - //! use actix_web::client::Client; - //! - //! #[actix_web::main] - //! async fn main() { - //! let mut client = Client::default(); - //! - //! // Create request builder and send request - //! let response = client.get("http://www.rust-lang.org") - //! .insert_header(("User-Agent", "actix-web/3.0")) - //! .send() // <- Send request - //! .await; // <- Wait for response - //! - //! println!("Response: {:?}", response); - //! } - //! ``` - - pub use awc::error::*; - pub use awc::{ - test, Client, ClientBuilder, ClientRequest, ClientResponse, Connector, - }; -} diff --git a/src/test.rs b/src/test.rs index 5da100b8..03113bd4 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1246,57 +1246,4 @@ mod tests { let res = app.call(req).await.unwrap(); assert!(res.status().is_success()); } - - #[actix_rt::test] - async fn test_actor() { - use crate::Error; - use actix::prelude::*; - - struct MyActor; - - impl Actor for MyActor { - type Context = Context; - } - - struct Num(usize); - - impl Message for Num { - type Result = usize; - } - - impl Handler for MyActor { - type Result = usize; - - fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result { - msg.0 - } - } - - let addr = MyActor.start(); - - async fn actor_handler( - addr: Data>, - ) -> Result { - let res = addr - .send(Num(1)) - .await - .map_err(crate::error::ErrorInternalServerError)?; - - if res == 1 { - Ok(HttpResponse::Ok()) - } else { - Ok(HttpResponse::BadRequest()) - } - } - - let srv = App::new() - .data(addr.clone()) - .service(web::resource("/").to(actor_handler)); - - let app = init_service(srv).await; - - let req = TestRequest::post().uri("/").to_request(); - let res = app.call(req).await.unwrap(); - assert!(res.status().is_success()); - } }