A crate to make trust-dns-resolver's asynchronous resolver compatible with hyper client, to use instead of the default dns threadpool.
By default hyper HttpConnector uses the std provided resolver wich is blocking in a threadpool with a configurable number of threads. This crate provides an alternative using trustdnsresolver, a dns resolver written in Rust, with async features.
trust-dns-resolver creates a background that needs to be spawned on top of an executor to run dns queries. It does not need to be spawned on the same executor as the client, but will deadlock if spawned on top of another executor that runs on the same thread.
```rust extern crate hypertrustdns_connector; extern crate hyper; extern crate tokio;
use hypertrustdnsconnector::newasynchttpconnector; use hyper::{Client, Body}; use tokio::runtime::Runtime;
fn main() { let mut rt = Runtime::new().expect("couldn't create runtime"); let (http, background) = newasynchttpconnector() .expect("couldn't create connector"); let client = Client::builder() .executor(rt.executor()) .build::<_, Body>(http); rt.spawn(background); let statuscode = rt .blockon(client.get(hyper::Uri::fromstatic("http://httpbin.org/ip"))) .map(|res| res.status()) .expect("error during the request"); println!("status is {:?}", status_code); } ```
If you need a feature implemented, or want to help, don't hesitate to open an issue or a PR.
Provided under the MIT license (LICENSE or http://opensource.org/licenses/MIT)