diff --git a/actix-connect/CHANGES.md b/actix-connect/CHANGES.md index a41a6837..12fbeed5 100644 --- a/actix-connect/CHANGES.md +++ b/actix-connect/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.1.2] - 2019-04-xx + +### Changed + +* Rename connect Connector to TcpConnector #10 + + ## [0.1.1] - 2019-03-15 ### Fixed diff --git a/actix-connect/Cargo.toml b/actix-connect/Cargo.toml index 7980480c..ebbf0ace 100644 --- a/actix-connect/Cargo.toml +++ b/actix-connect/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-connect" -version = "0.1.1" +version = "0.1.2" authors = ["Nikolay Kim "] description = "Actix Connector - tcp connector service" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-connect/src/connector.rs b/actix-connect/src/connector.rs index 33c4ce5b..7c5c178b 100644 --- a/actix-connect/src/connector.rs +++ b/actix-connect/src/connector.rs @@ -12,54 +12,54 @@ use super::error::ConnectError; /// Tcp connector service factory #[derive(Debug)] -pub struct ConnectorFactory(PhantomData); +pub struct TcpConnectorFactory(PhantomData); -impl ConnectorFactory { +impl TcpConnectorFactory { pub fn new() -> Self { - ConnectorFactory(PhantomData) + TcpConnectorFactory(PhantomData) } } -impl Clone for ConnectorFactory { +impl Clone for TcpConnectorFactory { fn clone(&self) -> Self { - ConnectorFactory(PhantomData) + TcpConnectorFactory(PhantomData) } } -impl NewService for ConnectorFactory { +impl NewService for TcpConnectorFactory { type Request = Connect; type Response = Connection; type Error = ConnectError; - type Service = Connector; + type Service = TcpConnector; type InitError = (); type Future = FutureResult; fn new_service(&self, _: &()) -> Self::Future { - ok(Connector(PhantomData)) + ok(TcpConnector(PhantomData)) } } /// Tcp connector service #[derive(Debug)] -pub struct Connector(PhantomData); +pub struct TcpConnector(PhantomData); -impl Connector { +impl TcpConnector { pub fn new() -> Self { - Connector(PhantomData) + TcpConnector(PhantomData) } } -impl Clone for Connector { +impl Clone for TcpConnector { fn clone(&self) -> Self { - Connector(PhantomData) + TcpConnector(PhantomData) } } -impl Service for Connector { +impl Service for TcpConnector { type Request = Connect; type Response = Connection; type Error = ConnectError; - type Future = Either, FutureResult>; + type Future = Either, FutureResult>; fn poll_ready(&mut self) -> Poll<(), Self::Error> { Ok(Async::Ready(())) @@ -70,7 +70,7 @@ impl Service for Connector { let Connect { req, addr, .. } = req; if let Some(addr) = addr { - Either::A(ConnectorResponse::new(req, port, addr)) + Either::A(TcpConnectorResponse::new(req, port, addr)) } else { error!("TCP connector: got unresolved address"); Either::B(err(ConnectError::Unresolverd)) @@ -80,19 +80,19 @@ impl Service for Connector { #[doc(hidden)] /// Tcp stream connector response future -pub struct ConnectorResponse { +pub struct TcpConnectorResponse { req: Option, port: u16, addrs: Option>, stream: Option, } -impl ConnectorResponse { +impl TcpConnectorResponse { pub fn new( req: T, port: u16, addr: either::Either>, - ) -> ConnectorResponse { + ) -> TcpConnectorResponse { trace!( "TCP connector - connecting to {:?} port:{}", req.host(), @@ -100,13 +100,13 @@ impl ConnectorResponse { ); match addr { - either::Either::Left(addr) => ConnectorResponse { + either::Either::Left(addr) => TcpConnectorResponse { req: Some(req), port, addrs: None, stream: Some(TcpStream::connect(&addr)), }, - either::Either::Right(addrs) => ConnectorResponse { + either::Either::Right(addrs) => TcpConnectorResponse { req: Some(req), port, addrs: Some(addrs), @@ -116,7 +116,7 @@ impl ConnectorResponse { } } -impl Future for ConnectorResponse { +impl Future for TcpConnectorResponse { type Item = Connection; type Error = ConnectError; diff --git a/actix-connect/src/lib.rs b/actix-connect/src/lib.rs index 11925cc4..6d7b0bc8 100644 --- a/actix-connect/src/lib.rs +++ b/actix-connect/src/lib.rs @@ -20,7 +20,7 @@ mod uri; pub use trust_dns_resolver::{error::ResolveError, AsyncResolver}; pub use self::connect::{Address, Connect, Connection}; -pub use self::connector::{Connector, ConnectorFactory}; +pub use self::connector::{TcpConnector, TcpConnectorFactory}; pub use self::error::ConnectError; pub use self::resolver::{Resolver, ResolverFactory}; @@ -29,6 +29,17 @@ use tokio_tcp::TcpStream; use trust_dns_resolver::config::{ResolverConfig, ResolverOpts}; use trust_dns_resolver::system_conf::read_system_conf; +#[doc(hidden)] +#[deprecated(since = "0.1.2", note = "please use `actix_connect::TcpConnector`")] +pub type Connector = TcpConnector; + +#[doc(hidden)] +#[deprecated( + since = "0.1.2", + note = "please use `actix_connect::TcpConnectorFactory`" +)] +pub type ConnectorFactory = TcpConnectorFactory; + pub fn start_resolver(cfg: ResolverConfig, opts: ResolverOpts) -> AsyncResolver { let (resolver, bg) = AsyncResolver::new(cfg, opts); tokio_current_thread::spawn(bg); @@ -52,7 +63,7 @@ pub fn new_connector( resolver: AsyncResolver, ) -> impl Service, Response = Connection, Error = ConnectError> + Clone { - Resolver::new(resolver).and_then(Connector::new()) + Resolver::new(resolver).and_then(TcpConnector::new()) } /// Create tcp connector service @@ -64,14 +75,14 @@ pub fn new_connector_factory( Error = ConnectError, InitError = (), > + Clone { - ResolverFactory::new(resolver).and_then(ConnectorFactory::new()) + ResolverFactory::new(resolver).and_then(TcpConnectorFactory::new()) } /// Create connector service with default parameters pub fn default_connector( ) -> impl Service, Response = Connection, Error = ConnectError> + Clone { - Resolver::new(start_default_resolver()).and_then(Connector::new()) + Resolver::new(start_default_resolver()).and_then(TcpConnector::new()) } /// Create connector service factory with default parameters @@ -81,5 +92,5 @@ pub fn default_connector_factory() -> impl NewService< Error = ConnectError, InitError = (), > + Clone { - ResolverFactory::new(start_default_resolver()).and_then(ConnectorFactory::new()) + ResolverFactory::new(start_default_resolver()).and_then(TcpConnectorFactory::new()) }