[PR #487] [MERGED] resolver: Split ResolverFuture into ResolverHandle and background task #1472

Closed
opened 2026-03-16 02:08:23 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/487
Author: @hawkw
Created: 5/24/2018
Status: Merged
Merged: 5/28/2018
Merged by: @bluejekyll

Base: masterHead: eliza/split-resolver-future


📝 Commits (5)

  • a713b86 resolver: Make ResolverFuture::lookup_ip lazier
  • 11e46ac resolver: Split ResolverFuture into ResolverHandle and Background task
  • d028b92 resolver: Rename Handle to AsyncResolver, add ResolverFuture alias
  • 091caf0 resolver: Document breaking change in resolver/CHANGELOG.md
  • b8747c5 resolver: Add more documentation on using the background future

📊 Changes

12 files changed (+692 additions, -352 deletions)

View changed files

📝 resolver/CHANGELOG.md (+9 -1)
📝 resolver/examples/global_resolver.rs (+25 -26)
📝 resolver/examples/multithreaded_runtime.rs (+23 -29)
resolver/src/async_resolver/background.rs (+232 -0)
📝 resolver/src/async_resolver/mod.rs (+325 -211)
📝 resolver/src/dns_sd.rs (+14 -20)
📝 resolver/src/lib.rs (+26 -7)
📝 resolver/src/lookup.rs (+2 -17)
📝 resolver/src/lookup_ip.rs (+2 -2)
📝 resolver/src/name_server_pool.rs (+8 -8)
📝 resolver/src/resolver.rs (+23 -28)
📝 resolver/src/tls/mod.rs (+3 -3)

📄 Description

Closes #464. Closes #430. Closes #481.

This PR splits the ResolverFuture into a separate ResolverHandle and a future that drives the name resolution work in the background.

This future can be run on a separate executor from the futures returned by ResolverHandle's lookup methods, but note that this only works if both executors are running simultaneously (i.e. they must be run in separate threads), so this does not fix #472; however, I don't think that it will be possible to fix that issue given the fact that a thread can only be executing one thing at a time.

In particular, you may want to check out this test I added, demonstrating that we can run the background task in a separate runtime on its' own thread from the futures returned by the ResolverHandle.

Also, note that a lot of the complexity in this branch is due to that I didn't want to make the whole resolver API return Box<Future<...> or impl Future<...>, everywhere, so there's a few kind of ugly type aliases; however, I think they're worth it because we can still return concrete types. I tried to update all of the documentation to describe the new API, but do let me know if I've missed anything.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/487 **Author:** [@hawkw](https://github.com/hawkw) **Created:** 5/24/2018 **Status:** ✅ Merged **Merged:** 5/28/2018 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `master` ← **Head:** `eliza/split-resolver-future` --- ### 📝 Commits (5) - [`a713b86`](https://github.com/hickory-dns/hickory-dns/commit/a713b86b69d5d371f1c90c91702544d920290c26) resolver: Make `ResolverFuture::lookup_ip` lazier - [`11e46ac`](https://github.com/hickory-dns/hickory-dns/commit/11e46aced54c0a559d8ab008c34a63ecdf055b5c) resolver: Split ResolverFuture into ResolverHandle and Background task - [`d028b92`](https://github.com/hickory-dns/hickory-dns/commit/d028b9200864769c0769a9b8cdcb2afaf4ba2705) resolver: Rename Handle to AsyncResolver, add ResolverFuture alias - [`091caf0`](https://github.com/hickory-dns/hickory-dns/commit/091caf01e663d288b2e129f0ba8aaeb1888eb2a1) resolver: Document breaking change in resolver/CHANGELOG.md - [`b8747c5`](https://github.com/hickory-dns/hickory-dns/commit/b8747c5c5719c7841bec5dd48ac1dfbc5eea87c0) resolver: Add more documentation on using the background future ### 📊 Changes **12 files changed** (+692 additions, -352 deletions) <details> <summary>View changed files</summary> 📝 `resolver/CHANGELOG.md` (+9 -1) 📝 `resolver/examples/global_resolver.rs` (+25 -26) 📝 `resolver/examples/multithreaded_runtime.rs` (+23 -29) ➕ `resolver/src/async_resolver/background.rs` (+232 -0) 📝 `resolver/src/async_resolver/mod.rs` (+325 -211) 📝 `resolver/src/dns_sd.rs` (+14 -20) 📝 `resolver/src/lib.rs` (+26 -7) 📝 `resolver/src/lookup.rs` (+2 -17) 📝 `resolver/src/lookup_ip.rs` (+2 -2) 📝 `resolver/src/name_server_pool.rs` (+8 -8) 📝 `resolver/src/resolver.rs` (+23 -28) 📝 `resolver/src/tls/mod.rs` (+3 -3) </details> ### 📄 Description Closes #464. Closes #430. Closes #481. This PR splits the `ResolverFuture` into a separate `ResolverHandle` and a future that drives the name resolution work in the background. This future can be run on a separate executor from the futures returned by `ResolverHandle`'s lookup methods, but note that this only works if both executors are running _simultaneously_ (i.e. they must be run in separate threads), so this does _not_ fix #472; however, I don't think that it will be possible to fix that issue given the fact that a thread can only be executing one thing at a time. In particular, you may want to check out [this test I added](https://github.com/hawkw/trust-dns/blob/5ad62f466e037245da35c8ed6c25c2c76704e83e/resolver/src/resolver_future.rs#L605-L639), demonstrating that we can run the background task in a separate runtime on its' own thread from the futures returned by the `ResolverHandle`. Also, note that a lot of the complexity in this branch is due to that I didn't want to make the whole resolver API return `Box<Future<...>` or `impl Future<...>`, everywhere, so there's a few kind of ugly type aliases; however, I think they're worth it because we can still return concrete types. I tried to update all of the documentation to describe the new API, but do let me know if I've missed anything. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 02:08:23 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1472
No description provided.