1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +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
## [0.1.4] - 2019-04-12
### Changed
* Do not start default resolver immediately for default connector.
## [0.1.3] - 2019-04-11
### Changed

View File

@ -1,6 +1,6 @@
[package]
name = "actix-connect"
version = "0.1.3"
version = "0.1.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix Connector - tcp connector service"
keywords = ["network", "framework", "async", "futures"]
@ -48,8 +48,8 @@ tokio-openssl = { version="0.3", optional = true }
[dev-dependencies]
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-utils = "0.3.4"
tokio-tcp = "0.1"

View File

@ -102,7 +102,7 @@ pub fn new_connector_factory<T: Address>(
pub fn default_connector<T: Address>(
) -> impl Service<Request = Connect<T>, Response = Connection<T, TcpStream>, Error = ConnectError>
+ Clone {
Resolver::new(start_default_resolver()).and_then(TcpConnector::new())
Resolver::default().and_then(TcpConnector::new())
}
/// Create connector service factory with default parameters
@ -112,5 +112,5 @@ pub fn default_connector_factory<T: Address>() -> impl NewService<
Error = ConnectError,
InitError = (),
> + 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};
#[cfg(feature = "ssl")]
#[test]
fn test_string() {
let mut srv = TestServer::with(|| {
@ -19,11 +20,9 @@ fn test_string() {
})
});
let mut conn = srv
.block_on(lazy(|| Ok::<_, ()>(default_connector())))
.unwrap();
let mut conn = default_connector();
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());
}
@ -92,6 +91,7 @@ fn test_new_service() {
assert_eq!(con.peer_addr().unwrap(), srv.addr());
}
#[cfg(feature = "ssl")]
#[test]
fn test_uri() {
let mut srv = TestServer::with(|| {
@ -102,10 +102,8 @@ fn test_uri() {
})
});
let mut conn = srv
.block_on(lazy(|| Ok::<_, ()>(default_connector())))
.unwrap();
let mut conn = default_connector();
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());
}