mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #1615] CachingClient::cache uses an immutable &self #710
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#710
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 @Noah-Wagner on GitHub (Jan 14, 2022).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1615
I found the following function where we insert new cache entries: caching_client.rs.
I am new to Rust and don't understand all of the idioms, but it is a little surprising to me that the
&selffor this function is immutable, as we appear to modify theCachingClient::lru_cache. While this compiles (due to Arc/Mutex mutability), I wonder if it would make sense to also make the&selfhere mutable to clearly document that we are mutating state on our class?@djc commented on GitHub (Jan 14, 2022):
It's a desirable property for the
ResolverorAsyncResolverto have resolving methods take&selfrather than&mut selfso you can share a single resolver in anArcand easily run queries from different threads or tasks. Conceptually it also makes sense that aResolveris not mutated whenever you run a resolver query. However, caching somewhat breaks that concept -- therefore the cache, in this case in the form of theCachingClient, contains an innerArc<Mutex<_>>to make sure that the outward appearance of immutability isn't "broken".Does that make sense?
@Noah-Wagner commented on GitHub (Jan 14, 2022):
This makes sense, thanks!