I just landed the the Client side Futures implementations for TRust-DNS into master. It’s a pretty easy conversion from the old client:
let result = client.query(record.get_name(), record.get_dns_class(), RecordType::A).unwrap()
let io_loop = tokio_core::reactor::Core::new().unwrap(); let result = io_loop.run(client.query(new.get_name(), new.get_dns_class(), RecordType::A, false)).unwrap().unwrap()
The difference here is that in the original client Mio was being used internally, not giving any control over the event loop to the caller. Now the caller is responsible for the event loop. The extra
unwrap() is for the result of the
Oneshot completion future, and then the actual
ClientResult which matches the original. This should allow the ClientFuture to be used in any Futures context and be compatible with other peoples Tokio based tools, which was the entire point of this month+ rewrite
ClientFuture::new() also takes an optional Signer. This is used right now for SIG0, which is the only auth method supported by TRust-DNS for dynamic DNS updates. I’ve been considering making a separate type for an UpdateClient and a standard QueryClient, though I haven’t figured out a clean way to do that yet.
The best examples I have for usage right now are in the tests:
I want to especially thank @alexcrichton for reviewing a lot of this code. He had many good pointers and explanations that helped me get this done. I think I incorporated all of those suggestions in
I may entirely remove the old Client, but it’s still there and works. The other option is to keep it as a facade over this implementation, presenting a simple blocking client.