From 7632f51509bb765819e7e5279fb60a7e3ae3e29c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 2 Sep 2020 22:14:07 +0100 Subject: [PATCH] prepare connect v2 stable release (#185) --- actix-connect/Cargo.toml | 15 ++++++++------- actix-connect/src/connect.rs | 9 +++++---- actix-connect/src/connector.rs | 9 +++++---- actix-connect/src/error.rs | 2 +- actix-connect/src/lib.rs | 14 +++++++------- actix-connect/src/resolve.rs | 1 + actix-connect/src/service.rs | 1 + actix-connect/src/ssl/openssl.rs | 7 ++++--- actix-connect/tests/test_connect.rs | 6 +++--- 9 files changed, 35 insertions(+), 29 deletions(-) diff --git a/actix-connect/Cargo.toml b/actix-connect/Cargo.toml index 3dfdb211..233195c5 100644 --- a/actix-connect/Cargo.toml +++ b/actix-connect/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "actix-connect" -version = "2.0.0-alpha.4" +version = "2.0.0" authors = ["Nikolay Kim "] -description = "Actix connect - tcp connector service" +description = "TCP connector service for Actix ecosystem." keywords = ["network", "framework", "async", "futures"] homepage = "https://actix.rs" repository = "https://github.com/actix/actix-net.git" @@ -31,10 +31,11 @@ rustls = ["rust-tls", "tokio-rustls", "webpki"] uri = ["http"] [dependencies] -actix-service = "1.0.3" +actix-service = "1.0.6" actix-codec = "0.3.0" actix-utils = "2.0.0" -actix-rt = "1.0.0" +actix-rt = "1.1.1" + derive_more = "0.99.2" either = "1.5.3" futures-util = { version = "0.3.4", default-features = false } @@ -44,14 +45,14 @@ trust-dns-proto = { version = "0.19", default-features = false, features = ["tok trust-dns-resolver = { version = "0.19", default-features = false, features = ["tokio-runtime", "system-config"] } # openssl -open-ssl = { version="0.10", package = "openssl", optional = true } +open-ssl = { package = "openssl", version = "0.10", optional = true } tokio-openssl = { version = "0.4.0", optional = true } # rustls -rust-tls = { version = "0.18.0", package = "rustls", optional = true } +rust-tls = { package = "rustls", version = "0.18.0", optional = true } tokio-rustls = { version = "0.14.0", optional = true } webpki = { version = "0.21", optional = true } [dev-dependencies] bytes = "0.5.3" -actix-testing = { version="1.0.0" } +actix-testing = "1.0.0" diff --git a/actix-connect/src/connect.rs b/actix-connect/src/connect.rs index f4f7f6b7..7d5531e5 100644 --- a/actix-connect/src/connect.rs +++ b/actix-connect/src/connect.rs @@ -43,7 +43,7 @@ pub struct Connect { } impl Connect { - /// Create `Connect` instance by spliting the string by ':' and convert the second part to u16 + /// Create `Connect` instance by splitting the string by ':' and convert the second part to u16 pub fn new(req: T) -> Connect { let (_, port) = parse(req.host()); Connect { @@ -53,7 +53,8 @@ impl Connect { } } - /// Create new `Connect` instance from host and address. Connector skips name resolution stage for such connect messages. + /// Create new `Connect` instance from host and address. Connector skips name resolution stage + /// for such connect messages. pub fn with(req: T, addr: SocketAddr) -> Connect { Connect { req, @@ -102,7 +103,7 @@ impl Connect { self.req.port().unwrap_or(self.port) } - /// Preresolved addresses of the request. + /// Pre-resolved addresses of the request. pub fn addrs(&self) -> ConnectAddrsIter<'_> { let inner = match self.addr { None => Either::Left(None), @@ -113,7 +114,7 @@ impl Connect { ConnectAddrsIter { inner } } - /// Takes preresolved addresses of the request. + /// Takes pre-resolved addresses of the request. pub fn take_addrs(&mut self) -> ConnectTakeAddrsIter { let inner = match self.addr.take() { None => Either::Left(None), diff --git a/actix-connect/src/connector.rs b/actix-connect/src/connector.rs index e9fb1525..9dc9a2ad 100644 --- a/actix-connect/src/connector.rs +++ b/actix-connect/src/connector.rs @@ -13,7 +13,7 @@ use futures_util::future::{err, ok, BoxFuture, Either, FutureExt, Ready}; use super::connect::{Address, Connect, Connection}; use super::error::ConnectError; -/// Tcp connector service factory +/// TCP connector service factory #[derive(Debug)] pub struct TcpConnectorFactory(PhantomData); @@ -22,7 +22,7 @@ impl TcpConnectorFactory { TcpConnectorFactory(PhantomData) } - /// Create tcp connector service + /// Create TCP connector service pub fn service(&self) -> TcpConnector { TcpConnector(PhantomData) } @@ -54,7 +54,7 @@ impl ServiceFactory for TcpConnectorFactory { } } -/// Tcp connector service +/// TCP connector service #[derive(Default, Debug)] pub struct TcpConnector(PhantomData); @@ -74,6 +74,7 @@ impl Service for TcpConnector { type Request = Connect; type Response = Connection; type Error = ConnectError; + #[allow(clippy::type_complexity)] type Future = Either, Ready>>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { @@ -94,7 +95,7 @@ impl Service for TcpConnector { } #[doc(hidden)] -/// Tcp stream connector response future +/// TCP stream connector response future pub struct TcpConnectorResponse { req: Option, port: u16, diff --git a/actix-connect/src/error.rs b/actix-connect/src/error.rs index 3c56f072..84b363dc 100644 --- a/actix-connect/src/error.rs +++ b/actix-connect/src/error.rs @@ -20,7 +20,7 @@ pub enum ConnectError { #[display(fmt = "Connector received `Connect` method with unresolved host")] Unresolved, - /// Connection io error + /// Connection IO error #[display(fmt = "{}", _0)] Io(io::Error), } diff --git a/actix-connect/src/lib.rs b/actix-connect/src/lib.rs index 85dcf99e..56e6a110 100644 --- a/actix-connect/src/lib.rs +++ b/actix-connect/src/lib.rs @@ -1,11 +1,11 @@ -//! Actix connect - tcp connector service +//! TCP connector service for Actix ecosystem. //! //! ## Package feature //! //! * `openssl` - enables ssl support via `openssl` crate //! * `rustls` - enables ssl support via `rustls` crate -#![deny(rust_2018_idioms, warnings)] -#![allow(clippy::type_complexity)] + +#![deny(rust_2018_idioms)] #![recursion_limit = "128"] #[macro_use] @@ -71,7 +71,7 @@ pub async fn start_default_resolver() -> Result { get_default_resolver().await } -/// Create tcp connector service +/// Create TCP connector service. pub fn new_connector( resolver: AsyncResolver, ) -> impl Service, Response = Connection, Error = ConnectError> @@ -79,7 +79,7 @@ pub fn new_connector( pipeline(Resolver::new(resolver)).and_then(TcpConnector::new()) } -/// Create tcp connector service +/// Create TCP connector service factory. pub fn new_connector_factory( resolver: AsyncResolver, ) -> impl ServiceFactory< @@ -92,14 +92,14 @@ pub fn new_connector_factory( pipeline_factory(ResolverFactory::new(resolver)).and_then(TcpConnectorFactory::new()) } -/// Create connector service with default parameters +/// Create connector service with default parameters. pub fn default_connector( ) -> impl Service, Response = Connection, Error = ConnectError> + Clone { pipeline(Resolver::default()).and_then(TcpConnector::new()) } -/// Create connector service factory with default parameters +/// Create connector service factory with default parameters. pub fn default_connector_factory() -> impl ServiceFactory< Config = (), Request = Connect, diff --git a/actix-connect/src/resolve.rs b/actix-connect/src/resolve.rs index faf68a19..bfb1482f 100644 --- a/actix-connect/src/resolve.rs +++ b/actix-connect/src/resolve.rs @@ -106,6 +106,7 @@ impl Service for Resolver { type Request = Connect; type Response = Connect; type Error = ConnectError; + #[allow(clippy::type_complexity)] type Future = Either< Pin>>>, Ready, Self::Error>>, diff --git a/actix-connect/src/service.rs b/actix-connect/src/service.rs index f337382b..1047e3df 100644 --- a/actix-connect/src/service.rs +++ b/actix-connect/src/service.rs @@ -114,6 +114,7 @@ enum ConnectState { } impl ConnectState { + #[allow(clippy::type_complexity)] fn poll( &mut self, cx: &mut Context<'_>, diff --git a/actix-connect/src/ssl/openssl.rs b/actix-connect/src/ssl/openssl.rs index 6858adbe..e1c6b6fb 100644 --- a/actix-connect/src/ssl/openssl.rs +++ b/actix-connect/src/ssl/openssl.rs @@ -17,7 +17,7 @@ use crate::{ Address, Connect, ConnectError, ConnectService, ConnectServiceFactory, Connection, }; -/// Openssl connector factory +/// OpenSSL connector factory pub struct OpensslConnector { connector: SslConnector, _t: PhantomData<(T, U)>, @@ -97,6 +97,7 @@ where type Request = Connection; type Response = Connection>; type Error = io::Error; + #[allow(clippy::type_complexity)] type Future = Either, Ready>>; fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll> { @@ -164,7 +165,7 @@ impl OpensslConnectServiceFactory { } } - /// Construct new connect service with custom dns resolver + /// Construct new connect service with custom DNS resolver pub fn with_resolver(connector: SslConnector, resolver: AsyncResolver) -> Self { OpensslConnectServiceFactory { tcp: ConnectServiceFactory::with_resolver(resolver), @@ -172,7 +173,7 @@ impl OpensslConnectServiceFactory { } } - /// Construct openssl connect service + /// Construct OpenSSL connect service pub fn service(&self) -> OpensslConnectService { OpensslConnectService { tcp: self.tcp.service(), diff --git a/actix-connect/tests/test_connect.rs b/actix-connect/tests/test_connect.rs index 549d559f..21d78d2c 100644 --- a/actix-connect/tests/test_connect.rs +++ b/actix-connect/tests/test_connect.rs @@ -88,9 +88,9 @@ async fn test_new_service() { assert_eq!(con.peer_addr().unwrap(), srv.addr()); } -#[cfg(feature = "openssl")] +#[cfg(all(feature = "openssl", feature = "uri"))] #[actix_rt::test] -async fn test_uri() { +async fn test_openssl_uri() { use std::convert::TryFrom; let srv = TestServer::with(|| { @@ -107,7 +107,7 @@ async fn test_uri() { assert_eq!(con.peer_addr().unwrap(), srv.addr()); } -#[cfg(feature = "rustls")] +#[cfg(all(feature = "rustls", feature = "uri"))] #[actix_rt::test] async fn test_rustls_uri() { use std::convert::TryFrom;