Open schveiguy opened 6 years ago
Also, I think it would be nice to put the wrapper function inside the dns module. Having to use the driver directly seems against the spirit of this library.
Hence it's private. I tried a couple of things, but getaddrinfo is really only designed to open a socket. On the good side, it can transparently handle IPv4 vs. IPv6 and multiple IPs if used correctly. DNS isn't a hostname -> addr mapping. And what would you do with a list of addresses of different families? My takeaway was to use the C resolver for sockets, but leave DNS to some other library. A real DNS library would also support other queries like MX, TXT, et.al. This reasoning should be properly documented somewhere.
What's the use-case for a manual DNS resolution of the hostname @schveiguy? Resolving names once on program startup is somewhat of an anti-pattern as it defies certain server-side failover/loadbalancer mechanisms (hence TTL in caching in recursive resolvers). Also sockets can be used over longer times, so repeated lookup shouldn't be too much of a problem, and most ppl. have caching resolvers nearby anyhow.
Hence it's private
Huh? I was able to use it here: https://github.com/schveiguy/httpiopipe/blob/master/source/iopipe/http.d#L591
DNS isn't a hostname -> addr mapping
I have no idea what you mean by this statement. What other service would I use to open a socket to a named host?
I think there's a misunderstanding here. I'm not complaining about the service or the usage of getaddrinfo, just that I have to use the driver directly (which is completely different from most of std.io), and that the API requires me to write my code in a node.js callback style of code.
What's the use-case for a manual DNS resolution of the hostname @schveiguy? Resolving names once on program startup is somewhat of an anti-pattern as it defies certain server-side failover/loadbalancer mechanisms (hence TTL in caching in recursive resolvers). Also sockets can be used over longer times, so repeated lookup shouldn't be too much of a problem, and most ppl. have caching resolvers nearby anyhow.
Literally, I have no idea why you wrote any of this. I really do feel you are reading some other meaning than what I wanted to say.
The current DNS lookup interface is clunky to say the least. You need to pass in a callback that is immediately called. Much better to return a struct.
I'd recommend one of 2 things: