[PR #481] [CLOSED] resolver: Make ResolverFuture::lookup_ip lazier #1469

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

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/481
Author: @hawkw
Created: 5/21/2018
Status: Closed

Base: masterHead: eliza/lazily-lookup-ip


📝 Commits (2)

  • c58722b resolver: Make ResolverFuture::lookup_ip lazier
  • c22ee4e Merge branch 'master' into eliza/lazily-lookup-ip

📊 Changes

2 files changed (+108 additions, -88 deletions)

View changed files

📝 resolver/examples/global_resolver.rs (+5 -1)
📝 resolver/src/resolver_future.rs (+103 -87)

📄 Description

This PR refactors the implementation of ResolverFuture::lookup_ip to lazily
prepare the LookupIpFuture when the returned future starts executing, rather
than eagerly when that function is called.

I took the simpler approach here and simply wrapped the preparation in a
future::lazy, rather than changing the implementation of LookupIpFuture.
This is because a number of Trust-DNS' tests construct LookupIpFutures
without first constructing a ResolverFuture, and changing LookupIpFuture
to do all the preparation done by ResolverFuture::lookup_ip would introduce
a significant amount of additional complexity to avoid breaking these tests.

Notably, the use of future::lazy here changes the return type from
ResolverFuture::lookup_ip to impl Future<...> rather than a concrete type.
If this API change is problematic downstream, we could add a new future type
that does the preparation and then becomes a LookupIpFuture, like I did
originally in hawkw/trust-dns@a76769e25f. I found
that this change makes the code more complex, but if being able to return a
concrete named type here presents a singificantly better API surface, I'd be
happy to change this branch to do that instead.

Closes #430

Signed-off-by: Eliza Weisman eliza@buoyant.io

/cc @briansmith


🔄 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/481 **Author:** [@hawkw](https://github.com/hawkw) **Created:** 5/21/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `eliza/lazily-lookup-ip` --- ### 📝 Commits (2) - [`c58722b`](https://github.com/hickory-dns/hickory-dns/commit/c58722be82972f047de246ed3facff517fde6cfe) resolver: Make `ResolverFuture::lookup_ip` lazier - [`c22ee4e`](https://github.com/hickory-dns/hickory-dns/commit/c22ee4ec312ae4bc2fc9bcb5b3bad5cd4ed5c513) Merge branch 'master' into eliza/lazily-lookup-ip ### 📊 Changes **2 files changed** (+108 additions, -88 deletions) <details> <summary>View changed files</summary> 📝 `resolver/examples/global_resolver.rs` (+5 -1) 📝 `resolver/src/resolver_future.rs` (+103 -87) </details> ### 📄 Description This PR refactors the implementation of `ResolverFuture::lookup_ip` to lazily prepare the `LookupIpFuture` when the returned future starts executing, rather than eagerly when that function is called. I took the simpler approach here and simply wrapped the preparation in a `future::lazy`, rather than changing the implementation of `LookupIpFuture`. This is because a number of Trust-DNS' tests construct `LookupIpFuture`s without first constructing a `ResolverFuture`, and changing `LookupIpFuture` to do all the preparation done by `ResolverFuture::lookup_ip` would introduce a significant amount of additional complexity to avoid breaking these tests. Notably, the use of `future::lazy` here changes the return type from `ResolverFuture::lookup_ip` to `impl Future<...>` rather than a concrete type. If this API change is problematic downstream, we could add a new future type that does the preparation and then becomes a `LookupIpFuture`, like I did originally in hawkw/trust-dns@a76769e25f075414d6aeae246168afc539506cbd. I found that this change makes the _code_ more complex, but if being able to return a concrete named type here presents a singificantly better _API surface_, I'd be happy to change this branch to do that instead. Closes #430 Signed-off-by: Eliza Weisman <eliza@buoyant.io> /cc @briansmith --- <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:07 +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#1469
No description provided.