mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #1933] Question: Mutex around AsyncClient #823
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#823
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 @andrewbaxter on GitHub (May 15, 2023).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1933
AsyncClient::querytakes a mutable self. SinceAsyncClientwill probably be used across threads, I'd expect it to be immutable. AFAICT wrapping inMutexworks fine, but it means you can't doclient.lock().unwrap().query().awaitsince the guard stays around until the query completes (you need to storeclient.lock().unwrap().query()in one statement then await it in the next).Should I be doing something else here?
For background, I'm writing the classic "DNS server that handles some requests locally and forwards the rest to 1.1.1.1".
@djc commented on GitHub (May 15, 2023):
You probably want to use a resolver rather than a client?
AsyncResolver::lookup()takes&self.@andrewbaxter commented on GitHub (May 15, 2023):
It seemed like it would be easier to map the parameters and return values from the values the
AsyncClientuses to that of theRequestHandlerif I'm just forwarding. The simplified interface doesn't take a lot of the request information and doesn't include a lot of the response information (authority, additional records, etc).I'm doing
maybe that architecture is mistaken.
@djc commented on GitHub (May 15, 2023):
Fair point. I think it would probably make sense that
AsyncClient::query()should take&selfand use some inner mechanism to deal with mutability (it looks like it just holds anmpsc::Senderunder the covers, which could just be cloned). If you want to work through what that needs, we'll definitely review your PR. I think the -client crate is relatively rarely used so there might still be reasons to look into -resolver instead depending on your exact use cases.@andrewbaxter commented on GitHub (May 15, 2023):
Okay cool, yeah. I haven't gotten very far but I'll come back to this once I've gotten my own code more stable.
Would it make more sense to provide an additional alternative query method in resolver that takes the same arguments as Client does for it's query (like
full_lookuporraw_lookuporadvanced_lookupor something)?I'm wondering if I shouldn't use resolver instead anyways for the things like using multiple servers, etc. I'm not sure if resolver has a simple interface just for user friendliness or out of necessity due to abstraction over multiple disparate backends.
@djc commented on GitHub (May 15, 2023):
Probably more for the simple interface, but you'll probably only find out for sure if you try! I think some kind of
full_lookup()(naming to be bikeshedded) probably makes sense.@ibigbug commented on GitHub (Sep 4, 2023):
I'm also facing the issue, made a PR here https://github.com/bluejekyll/trust-dns/pull/2018
@andrewbaxter commented on GitHub (Sep 23, 2023):
I think this is done in #2018 - I haven't checked but I'll close for now.