mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #188] Enable external io_loop in client library lookups #90
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#90
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lukaspustina on GitHub (Sep 17, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/188
Currently,
UdpClientConnection::newalways creates a new event loop:github.com/bluejekyll/trust-dns@c5ad6c9dd3/client/src/udp/udp_client_connection.rs (L46)So in case you want to run many lookups, the code creates a lot of
tokio_core::reactor::Coreinstances.I tries to construct a client manually in order to pass an existing event loop, but the fields of
UdpClientConnectionare private to this is currently not feasible:Is there an other way I haven't found yet to pass an external, already existing event loop to the client or would you consider adding the feature?
Thanks in advance, Lukas
@bluejekyll commented on GitHub (Sep 17, 2017):
Yes. I probably need more docs on this. The
UdpClientConnectionis designed to work with theSyncClientthe corollary for futures is theUdpClientStream. If you want access the tokio semantics, then the ClientFuture type should be used instead. By the way, if all you're doing is lookups, you may want to look at the resolver library, which is designed to do that in the same way as a OS resolver. I have a quick example in the Resolver library for working inside the Tokio framework.For the client you would follow something similar. The connection types you want would be TCP and UDP. You can use either with the ClientFuture type.
I have some tests that show all of this: https://github.com/bluejekyll/trust-dns/blob/master/integration-tests/tests/client_future_tests.rs#L47
If you don't mind, let me know where more, better documentation is needed. Clearly delineating the difference, and/or renaming the types mentioned here is probably necessary to make this more obvious. Many of these types were named over the evolution of the library, and thus the naming isn't necessarily clear. Clearing all of this up is something that should be done at some point.
@lukaspustina commented on GitHub (Sep 17, 2017):
Gnarz. Just looked at your text example. It's soo simple. I'll try it during the next few days and will check how the docs may be improved. Thanks so much!
I'll close the ticket once I'm done.
@lukaspustina commented on GitHub (Sep 18, 2017):
Perfect. It works. I'll check the docs later.
@bluejekyll commented on GitHub (Sep 18, 2017):
You may be interested in some logical changes I'm making to UDP and TCP usage coming in 0.5.1: #189
I'm just finishing up some mock tests for that, will probably release in the next few days.
@lukaspustina commented on GitHub (Sep 23, 2017):
Frist of all, as my pet project grows, I'm getting more and more into trust-dns as a DNS client and it's wonderful. The library has a great API, the docs are wonderful, and your code is an inspiration on many things. Especially, when I'm stuck with my poor Rust knowledge I turn to your code. Thank you so much for trust-dns.
Regarding the docs, what put me on the wrong track is the lack of an async client example in the docs. I just took a wrong turn and was trapped in the rabbit whole. I think in addition to the
SyncClientdocumentation (https://docs.rs/trust-dns/0.11.3/trust_dns/#querying) there should be an equivalent example forClientFuturelookups. I'm not sure though that you need to rename the async client into something obvious likeAsyncClient. From the futures crate's perspective this name makes sense and I'm afraidAsyncClientwouldn't make munch sense in the context of Futures. For example, it seems unidiomatic to use Future combinators on an object of typeAsyncClient.So, my best guess is to show the trust-dns first time use an async example alongside the sync example.
@bluejekyll commented on GitHub (Sep 23, 2017):
Thank you for the feedback. And your story is very encouraging, I’m glad this library could be of help.
Thanks for the feedback on the docs. I will add an async example as well to the client library. I’m trying to encourage people to move over to the Resolver for basic needs, but of course for many that’s not all they need.