mirror of
https://github.com/fafhrd91/actix-net
synced 2024-11-27 23:42:56 +01:00
Fix error handling for single address
This commit is contained in:
parent
b290273e81
commit
27c28d6597
@ -1,5 +1,12 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.1] - 2019-03-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fix error handling for single address
|
||||||
|
|
||||||
|
|
||||||
## [0.1.0] - 2019-03-14
|
## [0.1.0] - 2019-03-14
|
||||||
|
|
||||||
* Refactor resolver and connector services
|
* Refactor resolver and connector services
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-connect"
|
name = "actix-connect"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
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"]
|
||||||
|
@ -140,7 +140,7 @@ impl<T: Address> Future for ConnectorResponse<T> {
|
|||||||
self.req.as_ref().unwrap().host(),
|
self.req.as_ref().unwrap().host(),
|
||||||
self.port,
|
self.port,
|
||||||
);
|
);
|
||||||
if self.addrs.as_ref().unwrap().is_empty() {
|
if self.addrs.is_none() || self.addrs.as_ref().unwrap().is_empty() {
|
||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,9 @@ impl<T: Address> Future for ResolverFuture<T> {
|
|||||||
req.host(),
|
req.host(),
|
||||||
addrs
|
addrs
|
||||||
);
|
);
|
||||||
if addrs.len() == 1 {
|
if addrs.is_empty() {
|
||||||
|
Err(ConnectError::NoRecords)
|
||||||
|
} else if addrs.len() == 1 {
|
||||||
req.addr = Some(either::Either::Left(addrs.pop_front().unwrap()));
|
req.addr = Some(either::Either::Left(addrs.pop_front().unwrap()));
|
||||||
Ok(Async::Ready(req))
|
Ok(Async::Ready(req))
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,6 +26,7 @@ fn port(scheme: Option<&str>) -> Option<u16> {
|
|||||||
"wss" => Some(443),
|
"wss" => Some(443),
|
||||||
"amqp" => Some(5672),
|
"amqp" => Some(5672),
|
||||||
"amqps" => Some(5671),
|
"amqps" => Some(5671),
|
||||||
|
"sb" => Some(5671),
|
||||||
"mqtt" => Some(1883),
|
"mqtt" => Some(1883),
|
||||||
"mqtts" => Some(8883),
|
"mqtts" => Some(8883),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -43,13 +43,22 @@ fn test_static_str() {
|
|||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut conn = srv
|
let mut conn = srv
|
||||||
.block_on(lazy(|| Ok::<_, ()>(actix_connect::new_connector(resolver))))
|
.block_on(lazy(|| {
|
||||||
|
Ok::<_, ()>(actix_connect::new_connector(resolver.clone()))
|
||||||
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let con = srv
|
let con = srv
|
||||||
.block_on(conn.call(Connect::with("10", srv.addr())))
|
.block_on(conn.call(Connect::with("10", srv.addr())))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(con.peer_addr().unwrap(), srv.addr());
|
assert_eq!(con.peer_addr().unwrap(), srv.addr());
|
||||||
|
|
||||||
|
let connect = Connect::new(srv.host().to_owned());
|
||||||
|
let mut conn = srv
|
||||||
|
.block_on(lazy(|| Ok::<_, ()>(actix_connect::new_connector(resolver))))
|
||||||
|
.unwrap();
|
||||||
|
let con = srv.block_on(conn.call(connect));
|
||||||
|
assert!(con.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user