From f751cf5acb206e5ba11f8c8bae216468bde527f8 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sat, 9 Jan 2021 14:13:16 +0000 Subject: [PATCH] use convert err on forward_ready! (#246) --- actix-macros/src/lib.rs | 2 +- actix-router/CHANGES.md | 3 +++ actix-router/Cargo.toml | 2 +- actix-rt/src/runtime.rs | 2 +- actix-rt/src/system.rs | 4 ++-- actix-server/CHANGES.md | 3 +++ actix-server/src/builder.rs | 5 ----- actix-server/src/test_server.rs | 9 +++------ actix-server/tests/test_server.rs | 8 ++++---- actix-service/CHANGES.md | 3 +++ actix-service/src/fn_service.rs | 4 ++-- actix-service/src/lib.rs | 10 ++++++---- actix-service/src/transform.rs | 8 +++----- actix-tracing/src/lib.rs | 2 +- actix-utils/src/timeout.rs | 4 +--- 15 files changed, 34 insertions(+), 35 deletions(-) diff --git a/actix-macros/src/lib.rs b/actix-macros/src/lib.rs index fc655a64..dd791578 100644 --- a/actix-macros/src/lib.rs +++ b/actix-macros/src/lib.rs @@ -11,7 +11,7 @@ use quote::quote; /// /// ## Usage /// -/// ```rust +/// ``` /// #[actix_rt::main] /// async fn main() { /// println!("Hello world"); diff --git a/actix-router/CHANGES.md b/actix-router/CHANGES.md index 85ac7a78..e9d4c3a2 100644 --- a/actix-router/CHANGES.md +++ b/actix-router/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx +* Use `bytestring` version range compatible with Bytes v1.0. [#246] + +[#246]: https://github.com/actix/actix-net/pull/246 ## 0.2.5 - 2020-09-20 diff --git a/actix-router/Cargo.toml b/actix-router/Cargo.toml index 6fc6ecc8..74e5fdab 100644 --- a/actix-router/Cargo.toml +++ b/actix-router/Cargo.toml @@ -20,7 +20,7 @@ default = ["http"] [dependencies] regex = "1.3.1" serde = "1.0.104" -bytestring = "0.1.2" +bytestring = ">=0.1.5, <2" log = "0.4.8" http = { version = "0.2.2", optional = true } diff --git a/actix-rt/src/runtime.rs b/actix-rt/src/runtime.rs index a72f492c..63653e13 100644 --- a/actix-rt/src/runtime.rs +++ b/actix-rt/src/runtime.rs @@ -41,7 +41,7 @@ impl Runtime { /// /// # Examples /// - /// ```rust,ignore + /// ```ignore /// # use futures::{future, Future, Stream}; /// use actix_rt::Runtime; /// diff --git a/actix-rt/src/system.rs b/actix-rt/src/system.rs index 1fbbc0ee..3a199da7 100644 --- a/actix-rt/src/system.rs +++ b/actix-rt/src/system.rs @@ -70,7 +70,7 @@ impl System { /// /// # Examples /// - /// ```rust,ignore + /// ```ignore /// use tokio::{runtime::Runtime, task::LocalSet}; /// use actix_rt::System; /// use futures_util::future::try_join_all; @@ -139,7 +139,7 @@ impl System { /// /// # Examples /// - /// ```rust,ignore + /// ```ignore /// use tokio::runtime::Runtime; /// use actix_rt::System; /// use futures_util::future::try_join_all; diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index d02643e6..70728064 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx +* Hidden `ServerBuilder::start` method has been removed. Use `ServerBuilder::run`. [#246] + +[#246]: https://github.com/actix/actix-net/pull/246 ## 2.0.0-beta.2 - 2021-01-03 diff --git a/actix-server/src/builder.rs b/actix-server/src/builder.rs index 51dd0eda..13c164f1 100644 --- a/actix-server/src/builder.rs +++ b/actix-server/src/builder.rs @@ -252,11 +252,6 @@ impl ServerBuilder { Ok(self) } - #[doc(hidden)] - pub fn start(self) -> Server { - self.run() - } - /// Starts processing incoming connections and return server controller. pub fn run(mut self) -> Server { if self.sockets.is_empty() { diff --git a/actix-server/src/test_server.rs b/actix-server/src/test_server.rs index 627cc675..4b7f7873 100644 --- a/actix-server/src/test_server.rs +++ b/actix-server/src/test_server.rs @@ -12,7 +12,7 @@ use crate::{Server, ServerBuilder, ServiceFactory}; /// /// # Examples /// -/// ```rust +/// ``` /// use actix_service::fn_service; /// use actix_server::TestServer; /// @@ -49,10 +49,7 @@ impl TestServer { // run server in separate thread thread::spawn(move || { let sys = System::new("actix-test-server"); - factory(Server::build()) - .workers(1) - .disable_signals() - .start(); + factory(Server::build()).workers(1).disable_signals().run(); tx.send(System::current()).unwrap(); sys.run() @@ -83,7 +80,7 @@ impl TestServer { .unwrap() .workers(1) .disable_signals() - .start(); + .run(); tx.send((System::current(), local_addr)).unwrap(); }); sys.run() diff --git a/actix-server/tests/test_server.rs b/actix-server/tests/test_server.rs index 2604df74..8d93ba0b 100644 --- a/actix-server/tests/test_server.rs +++ b/actix-server/tests/test_server.rs @@ -28,7 +28,7 @@ fn test_bind() { .disable_signals() .bind("test", addr, move || fn_service(|_| ok::<_, ()>(()))) .unwrap() - .start() + .run() })); let _ = tx.send((srv, actix_rt::System::current())); let _ = sys.run(); @@ -55,7 +55,7 @@ fn test_listen() { .workers(1) .listen("test", lst, move || fn_service(|_| ok::<_, ()>(()))) .unwrap() - .start(); + .run(); let _ = tx.send(actix_rt::System::current()); }); let _ = sys.run(); @@ -94,7 +94,7 @@ fn test_start() { }) }) .unwrap() - .start() + .run() })); let _ = tx.send((srv, actix_rt::System::current())); @@ -173,7 +173,7 @@ fn test_configure() { }) .unwrap() .workers(1) - .start() + .run() })); let _ = tx.send((srv, actix_rt::System::current())); let _ = sys.run(); diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index bff9bda5..53398894 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,6 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx +* The `forward_ready!` macro converts errors. [#246] + +[#246]: https://github.com/actix/actix-net/pull/246 ## 2.0.0-beta.2 - 2021-01-03 diff --git a/actix-service/src/fn_service.rs b/actix-service/src/fn_service.rs index 9f7d1eb7..5f09c580 100644 --- a/actix-service/src/fn_service.rs +++ b/actix-service/src/fn_service.rs @@ -17,7 +17,7 @@ where /// /// # Example /// -/// ```rust +/// ``` /// use std::io; /// use actix_service::{fn_factory, fn_service, Service, ServiceFactory}; /// use futures_util::future::ok; @@ -67,7 +67,7 @@ where /// /// # Example /// -/// ```rust +/// ``` /// use std::io; /// use actix_service::{fn_factory_with_config, fn_service, Service, ServiceFactory}; /// use futures_util::future::ok; diff --git a/actix-service/src/lib.rs b/actix-service/src/lib.rs index 7bf979e5..b774d0d9 100644 --- a/actix-service/src/lib.rs +++ b/actix-service/src/lib.rs @@ -48,7 +48,7 @@ use self::ready::{err, ok, ready, Ready}; /// replies. You can think about a service as a function with one argument that returns some result /// asynchronously. Conceptually, the operation looks like this: /// -/// ```rust,ignore +/// ```ignore /// async fn(Request) -> Result /// ``` /// @@ -60,7 +60,7 @@ use self::ready::{err, ok, ready, Ready}; /// simple API surfaces. This leads to simpler design of each service, improves test-ability and /// makes composition easier. /// -/// ```rust,ignore +/// ```ignore /// struct MyService; /// /// impl Service for MyService { @@ -78,7 +78,7 @@ use self::ready::{err, ok, ready, Ready}; /// Sometimes it is not necessary to implement the Service trait. For example, the above service /// could be rewritten as a simple function and passed to [fn_service](fn_service()). /// -/// ```rust,ignore +/// ```ignore /// async fn my_service(req: u8) -> Result; /// ``` pub trait Service { @@ -327,7 +327,9 @@ macro_rules! forward_ready { &mut self, cx: &mut ::core::task::Context<'_>, ) -> ::core::task::Poll> { - self.$field.poll_ready(cx) + self.$field + .poll_ready(cx) + .map_err(::core::convert::Into::into) } }; } diff --git a/actix-service/src/transform.rs b/actix-service/src/transform.rs index 76e4547a..7d707d98 100644 --- a/actix-service/src/transform.rs +++ b/actix-service/src/transform.rs @@ -30,7 +30,7 @@ where /// /// For example, timeout transform: /// -/// ```rust,ignore +/// ```ignore /// pub struct Timeout { /// service: S, /// timeout: Duration, @@ -45,9 +45,7 @@ where /// type Error = TimeoutError; /// type Future = TimeoutServiceResponse; /// -/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { -/// ready!(self.service.poll_ready(cx)).map_err(TimeoutError::Service) -/// } +/// actix_service::forward_ready!(service); /// /// fn call(&mut self, req: S::Request) -> Self::Future { /// TimeoutServiceResponse { @@ -69,7 +67,7 @@ where /// /// Factory for `Timeout` middleware from the above example could look like this: /// -/// ```rust,,ignore +/// ```ignore /// pub struct TimeoutTransform { /// timeout: Duration, /// } diff --git a/actix-tracing/src/lib.rs b/actix-tracing/src/lib.rs index 6d37d9b3..77a16287 100644 --- a/actix-tracing/src/lib.rs +++ b/actix-tracing/src/lib.rs @@ -94,7 +94,7 @@ where /// is passed in a reference to the request being handled by the service. /// /// For example: -/// ```rust,ignore +/// ```ignore /// let traced_service = trace( /// web_service, /// |req: &Request| Some(span!(Level::INFO, "request", req.id)) diff --git a/actix-utils/src/timeout.rs b/actix-utils/src/timeout.rs index 85e328b9..a308b0db 100644 --- a/actix-utils/src/timeout.rs +++ b/actix-utils/src/timeout.rs @@ -149,9 +149,7 @@ where type Error = TimeoutError; type Future = TimeoutServiceResponse; - fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { - self.service.poll_ready(cx).map_err(TimeoutError::Service) - } + actix_service::forward_ready!(service); fn call(&mut self, request: Req) -> Self::Future { TimeoutServiceResponse {