upgrade trust-dns-resolver to Tokio 0.3

This commit is contained in:
Benjamin Fry
2020-11-10 09:42:04 -08:00
parent a9a831fc1a
commit 402a14abce
14 changed files with 80 additions and 96 deletions

View File

@@ -30,7 +30,7 @@ use crate::name_server::{
RuntimeProvider,
};
#[cfg(feature = "tokio-runtime")]
use crate::name_server::{TokioConnection, TokioConnectionProvider};
use crate::name_server::{TokioConnection, TokioConnectionProvider, TokioHandle};
use crate::Hosts;
@@ -130,8 +130,7 @@ impl TokioAsyncResolver {
/// documentation for `AsyncResolver` for more information on how to use
/// the background future.
pub fn tokio(config: ResolverConfig, options: ResolverOpts) -> Result<Self, ResolveError> {
use tokio::runtime::Handle;
Self::new(config, options, Handle::current())
Self::new(config, options, TokioHandle)
}
/// Constructs a new Tokio based Resolver with the system configuration.
@@ -140,8 +139,7 @@ impl TokioAsyncResolver {
#[cfg(any(unix, target_os = "windows"))]
#[cfg(feature = "system-config")]
pub fn tokio_from_system_conf() -> Result<Self, ResolveError> {
use tokio::runtime::Handle;
Self::from_system_conf(Handle::current())
Self::from_system_conf(TokioHandle)
}
}
@@ -1089,7 +1087,7 @@ mod tests {
fn test_lookup_google() {
use super::testing::lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
lookup_test::<Runtime, TokioRuntime>(ResolverConfig::google(), io_loop, handle)
}
@@ -1097,7 +1095,7 @@ mod tests {
fn test_lookup_cloudflare() {
use super::testing::lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
lookup_test::<Runtime, TokioRuntime>(ResolverConfig::cloudflare(), io_loop, handle)
}
@@ -1105,7 +1103,7 @@ mod tests {
fn test_lookup_quad9() {
use super::testing::lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
lookup_test::<Runtime, TokioRuntime>(ResolverConfig::quad9(), io_loop, handle)
}
@@ -1113,15 +1111,15 @@ mod tests {
fn test_ip_lookup() {
use super::testing::ip_lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
ip_lookup_test::<Runtime, TokioRuntime>(io_loop, handle)
}
#[test]
fn test_ip_lookup_across_threads() {
use super::testing::ip_lookup_across_threads_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let _io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = TokioHandle;
ip_lookup_across_threads_test::<Runtime, TokioRuntime>(handle)
}
@@ -1130,7 +1128,7 @@ mod tests {
fn test_sec_lookup() {
use super::testing::sec_lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
sec_lookup_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1139,7 +1137,7 @@ mod tests {
fn test_sec_lookup_fails() {
use super::testing::sec_lookup_fails_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
sec_lookup_fails_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1150,7 +1148,7 @@ mod tests {
fn test_system_lookup() {
use super::testing::system_lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
system_lookup_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1161,7 +1159,7 @@ mod tests {
fn test_hosts_lookup() {
use super::testing::hosts_lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
hosts_lookup_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1169,7 +1167,7 @@ mod tests {
fn test_fqdn() {
use super::testing::fqdn_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
fqdn_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1177,7 +1175,7 @@ mod tests {
fn test_ndots() {
use super::testing::ndots_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
ndots_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1185,7 +1183,7 @@ mod tests {
fn test_large_ndots() {
use super::testing::large_ndots_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
large_ndots_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1193,7 +1191,7 @@ mod tests {
fn test_domain_search() {
use super::testing::domain_search_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
domain_search_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1201,7 +1199,7 @@ mod tests {
fn test_search_list() {
use super::testing::search_list_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
search_list_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1209,7 +1207,7 @@ mod tests {
fn test_idna() {
use super::testing::idna_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
idna_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1217,7 +1215,7 @@ mod tests {
fn test_localhost_ipv4() {
use super::testing::localhost_ipv4_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
localhost_ipv4_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1225,7 +1223,7 @@ mod tests {
fn test_localhost_ipv6() {
use super::testing::localhost_ipv6_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
localhost_ipv6_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1233,7 +1231,7 @@ mod tests {
fn test_search_ipv4_large_ndots() {
use super::testing::search_ipv4_large_ndots_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
search_ipv4_large_ndots_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1241,7 +1239,7 @@ mod tests {
fn test_search_ipv6_large_ndots() {
use super::testing::search_ipv6_large_ndots_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
search_ipv6_large_ndots_test::<Runtime, TokioRuntime>(io_loop, handle);
}
@@ -1249,7 +1247,7 @@ mod tests {
fn test_search_ipv6_name_parse_fails() {
use super::testing::search_ipv6_name_parse_fails_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime io_loop");
let handle = io_loop.handle().clone();
let handle = TokioHandle;
search_ipv6_name_parse_fails_test::<Runtime, TokioRuntime>(io_loop, handle);
}
}