[GH-ISSUE #464] Split ResolverFuture::new() into two returns (ResolverHandle, ResolverRuntime) #496

Closed
opened 2026-03-15 22:48:31 +03:00 by kerem · 4 comments
Owner

Originally created by @bluejekyll on GitHub (May 14, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/464

Names TBD.

At the moment, ResolverFuture returns a lazily evaluated future of Self. This makes it complicated to use in multithreaded situations. The reason for this is that there are really two separate parts to the resolver, but one is hidden at the moment. The hidden part is the registration of the network connections, etc, in the NameServerPool and it's associated NameServers.

The proposed ResolverHandle (name TBD) would have an API identical to ResolverFuture today. It's responsibility would be identical to that of the ResolverFuture today, which is to use the handles to the NameServers to make requests.

The ResolverRuntime needs to be run in the background. This can be on the same thread as the ResolverHandle requests or on a separate thread. It should be spawned, and shut itself down when there are no more ResolverHandle's outstanding to it. To refactor the library to return this future, rather than spawning implicitly will take a bit of work, potentially all the way down into the proto library.

This should improve the experience of constructing and then using the Resolver...

Originally created by @bluejekyll on GitHub (May 14, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/464 Names TBD. At the moment, `ResolverFuture` returns a lazily evaluated future of `Self`. This makes it complicated to use in multithreaded situations. The reason for this is that there are really two separate parts to the resolver, but one is hidden at the moment. The hidden part is the registration of the network connections, etc, in the `NameServerPool` and it's associated `NameServer`s. The proposed `ResolverHandle` (name TBD) would have an API identical to `ResolverFuture` today. It's responsibility would be identical to that of the `ResolverFuture` today, which is to use the handles to the `NameServers` to make requests. The `ResolverRuntime` needs to be run in the background. This can be on the same thread as the `ResolverHandle` requests or on a separate thread. It should be spawned, and shut itself down when there are no more `ResolverHandle's` outstanding to it. To refactor the library to return this future, rather than spawning implicitly will take a bit of work, potentially all the way down into the proto library. This should improve the experience of constructing and then using the Resolver...
kerem 2026-03-15 22:48:31 +03:00
Author
Owner

@hawkw commented on GitHub (May 23, 2018):

I have some thoughts on how to do this. I'd be happy to start a branch.

<!-- gh-comment-id:391446942 --> @hawkw commented on GitHub (May 23, 2018): I have some thoughts on how to do this. I'd be happy to start a branch.
Author
Owner

@bluejekyll commented on GitHub (May 23, 2018):

I’m open to other proposals as well... this was just my first take on what might be needed.

<!-- gh-comment-id:391448698 --> @bluejekyll commented on GitHub (May 23, 2018): I’m open to other proposals as well... this was just my first take on what might be needed.
Author
Owner

@hawkw commented on GitHub (May 23, 2018):

Well, I'm not going to make any promises until it's done, but I think I've worked out a way of making this change without touching anything outside of the resolver crate.

<!-- gh-comment-id:391461936 --> @hawkw commented on GitHub (May 23, 2018): Well, I'm not going to make any promises until it's done, but I _think_ I've worked out a way of making this change without touching anything outside of the resolver crate.
Author
Owner

@hawkw commented on GitHub (May 23, 2018):

Okay, I have a working first pass on this in this branch.

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.

This branch probably still needs a little more polish before its' ready for prime-time. I think some of the code can be cleaned up, and it probably needs more documentation updates.

<!-- gh-comment-id:391528425 --> @hawkw commented on GitHub (May 23, 2018): Okay, I have a working first pass on this in [this branch](https://github.com/bluejekyll/trust-dns/compare/master...hawkw:eliza/split-resolver-future?expand=1). 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`. This branch probably still needs a little more polish before its' ready for prime-time. I think some of the code can be cleaned up, and it probably needs more documentation updates.
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#496
No description provided.