1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-28 00:42:58 +01:00

Do not start default resolver immediately for default connector.

This commit is contained in:
Nikolay Kim 2019-04-12 12:28:18 -07:00
parent 21507d3da1
commit d3208bf7a8
4 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,12 @@
# Changes # Changes
## [0.1.4] - 2019-04-12
### Changed
* Do not start default resolver immediately for default connector.
## [0.1.3] - 2019-04-11 ## [0.1.3] - 2019-04-11
### Changed ### Changed

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-connect" name = "actix-connect"
version = "0.1.3" version = "0.1.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Connector - tcp connector service" description = "Actix Connector - tcp connector service"
keywords = ["network", "framework", "async", "futures"] keywords = ["network", "framework", "async", "futures"]
@ -48,8 +48,8 @@ tokio-openssl = { version="0.3", optional = true }
[dev-dependencies] [dev-dependencies]
bytes = "0.4" bytes = "0.4"
actix-connect = { path=".", features=["ssl"] } #actix-test-server = { version="0.2.0", features=["ssl"] }
actix-test-server = { version="0.2.0", features=["ssl"] } actix-test-server = { path="../actix-test-server", features=["ssl"] }
actix-server-config = "0.1.0" actix-server-config = "0.1.0"
actix-utils = "0.3.4" actix-utils = "0.3.4"
tokio-tcp = "0.1" tokio-tcp = "0.1"

View File

@ -102,7 +102,7 @@ pub fn new_connector_factory<T: Address>(
pub fn default_connector<T: Address>( pub fn default_connector<T: Address>(
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError> ) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
+ Clone { + Clone {
Resolver::new(start_default_resolver()).and_then(TcpConnector::new()) Resolver::default().and_then(TcpConnector::new())
} }
/// Create connector service factory with default parameters /// Create connector service factory with default parameters
@ -112,5 +112,5 @@ pub fn default_connector_factory<T: Address>() -> impl NewService<
Error = ConnectError, Error = ConnectError,
InitError = (), InitError = (),
> + Clone { > + Clone {
ResolverFactory::new(start_default_resolver()).and_then(TcpConnectorFactory::new()) ResolverFactory::default().and_then(TcpConnectorFactory::new())
} }

View File

@ -9,6 +9,7 @@ use trust_dns_resolver::config::{ResolverConfig, ResolverOpts};
use actix_connect::{default_connector, Connect}; use actix_connect::{default_connector, Connect};
#[cfg(feature = "ssl")]
#[test] #[test]
fn test_string() { fn test_string() {
let mut srv = TestServer::with(|| { let mut srv = TestServer::with(|| {
@ -19,11 +20,9 @@ fn test_string() {
}) })
}); });
let mut conn = srv let mut conn = default_connector();
.block_on(lazy(|| Ok::<_, ()>(default_connector())))
.unwrap();
let addr = format!("localhost:{}", srv.port()); let addr = format!("localhost:{}", srv.port());
let con = srv.block_on(conn.call(addr.into())).unwrap(); let con = srv.run_on(move || conn.call(addr.into())).unwrap();
assert_eq!(con.peer_addr().unwrap(), srv.addr()); assert_eq!(con.peer_addr().unwrap(), srv.addr());
} }
@ -92,6 +91,7 @@ fn test_new_service() {
assert_eq!(con.peer_addr().unwrap(), srv.addr()); assert_eq!(con.peer_addr().unwrap(), srv.addr());
} }
#[cfg(feature = "ssl")]
#[test] #[test]
fn test_uri() { fn test_uri() {
let mut srv = TestServer::with(|| { let mut srv = TestServer::with(|| {
@ -102,10 +102,8 @@ fn test_uri() {
}) })
}); });
let mut conn = srv let mut conn = default_connector();
.block_on(lazy(|| Ok::<_, ()>(default_connector())))
.unwrap();
let addr = Uri::try_from(format!("https://localhost:{}", srv.port())).unwrap(); let addr = Uri::try_from(format!("https://localhost:{}", srv.port())).unwrap();
let con = srv.block_on(conn.call(addr.into())).unwrap(); let con = srv.run_on(move || conn.call(addr.into())).unwrap();
assert_eq!(con.peer_addr().unwrap(), srv.addr()); assert_eq!(con.peer_addr().unwrap(), srv.addr());
} }