Skip to content

Commit

Permalink
Make dns resolution async, in async runtime (#606)
Browse files Browse the repository at this point in the history
fixes: #379
  • Loading branch information
Roger committed May 18, 2022
1 parent 6202e41 commit 867de8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -37,7 +37,7 @@ bytes = { version = "1", optional = true }
futures-util = { version = "0.3.15", default-features = false, optional = true }
pin-project-lite = { version = "0.2", optional = true }
tokio-util = { version = "0.7", optional = true }
tokio = { version = "1", features = ["rt"], optional = true }
tokio = { version = "1", features = ["rt", "net"], optional = true }

# Only needed for the connection manager
arc-swap = { version = "1.1.0", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions src/aio.rs
Expand Up @@ -4,7 +4,6 @@ use std::collections::VecDeque;
use std::io;
use std::mem;
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
#[cfg(unix)]
use std::path::Path;
use std::pin::Pin;
Expand All @@ -14,6 +13,7 @@ use combine::{parser::combinator::AnySendSyncPartialState, stream::PointerOffset

use ::tokio::{
io::{AsyncRead, AsyncWrite, AsyncWriteExt},
net::lookup_host,
sync::{mpsc, oneshot},
};

Expand Down Expand Up @@ -456,7 +456,7 @@ pub(crate) async fn connect_simple<T: RedisRuntime>(
) -> RedisResult<T> {
Ok(match connection_info.addr {
ConnectionAddr::Tcp(ref host, port) => {
let socket_addr = get_socket_addrs(host, port)?;
let socket_addr = get_socket_addrs(host, port).await?;
<T>::connect_tcp(socket_addr).await?
}

Expand All @@ -466,7 +466,7 @@ pub(crate) async fn connect_simple<T: RedisRuntime>(
port,
insecure,
} => {
let socket_addr = get_socket_addrs(host, port)?;
let socket_addr = get_socket_addrs(host, port).await?;
<T>::connect_tcp_tls(host, socket_addr, insecure).await?
}

Expand All @@ -492,8 +492,8 @@ pub(crate) async fn connect_simple<T: RedisRuntime>(
})
}

fn get_socket_addrs(host: &str, port: u16) -> RedisResult<SocketAddr> {
let mut socket_addrs = (host, port).to_socket_addrs()?;
async fn get_socket_addrs(host: &str, port: u16) -> RedisResult<SocketAddr> {
let mut socket_addrs = lookup_host((host, port)).await?;
match socket_addrs.next() {
Some(socket_addr) => Ok(socket_addr),
None => Err(RedisError::from((
Expand Down

0 comments on commit 867de8a

Please sign in to comment.