nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
6.16k stars 532 forks source link

Balanced Pool DNS lookup #1066

Open ronag opened 2 years ago

ronag commented 2 years ago

It would be useful if balanced pool would do a dns lookup on non ip upstreams to loadbalance between all ips in the dns record.

JacopoPatroclo commented 9 months ago

@ronag Hi, I would love to contribute to this. I have one question: The functionality related to the upstream addition to the pool is synchronous (addUpstream) but the DNS resolution must be an asynchronous call. This may require a braking change in the API. If what I wrote makes sense; how do you propose to address this? Otherwise, I would like to know why I am wrong so that I can do the actual implementation. Thanks!

metcoder95 commented 9 months ago

Hey! I'd suggest you take a look at ProxyAgent and how does it intercepts the connect step of the Client to create the Proxy.

Here, there's no need to do the resolution right away, it can be delayed up to usage if the flag is enabled.