Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIO's Resolver interface pretty much forces thread hops for external Resolvers #2435

Open
weissi opened this issue May 27, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@weissi
Copy link
Member

weissi commented May 27, 2023

func initiateAQuery(host: String, port: Int) -> EventLoopFuture<[SocketAddress]>

NIO's resolver interface doesn't tell the resolver what EventLoop the returned future should ideally be coming from.
That means that a normal resolver will likely return futures of a random EL which is bad for performance and unnecessary.

NIO's own GAIResolver kinda cheats and gets constructed inside ClientBootstrap -- after it has selected the EL for the new Channel. That possibility doesn't exist for outside resolvers because they need to be initialised when added to ClientBootstrap.resolver(instanceHere).

yes, you can manually pick an EL, pass that to the ClientBootstrap as the group and also pass it to your resolver but that's brittle, error-prone, reimplementing NIO functionality and probably also precludes a multi-shot resolver from caching.

@weissi
Copy link
Member Author

weissi commented May 27, 2023

@Lukasa should we invent a new label like needs-major that is something like easy-in-major-challenging-in-minor for issues (like this one) that are possible (but ugly/hard) to be fixed in minors (adding new interfaces that overlap with old ones) but would be incredibly easy in a minor.

Then once NIO3 comes around they can just be done.

@weissi weissi changed the title NIO's Resolver interface pretty much forces thread hops NIO's Resolver interface pretty much forces thread hops for external Resolvers May 27, 2023
@Lukasa Lukasa added the enhancement New feature or request label May 28, 2023
@dnadoba
Copy link
Member

dnadoba commented May 31, 2023

If you know the EventLoopGroup you can use .any() to get the "current" EventLoop and avoid thread hops without passing the EventLoop to any of the Resolver methods explicitly because they are called while being on the EventLoop.

@weissi
Copy link
Member Author

weissi commented Jun 5, 2023

If you know the EventLoopGroup you can use .any() to get the "current" EventLoop and avoid thread hops without passing the EventLoop to any of the Resolver methods explicitly because they are called while being on the EventLoop.

Sure, but that's not "guaranteed" to work and just unnecessarily ugly :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants