On Thu, Jun 17, 2021 at 8:29 AM Chris Angelico rosuav@gmail.com wrote:
On Thu, Jun 17, 2021 at 7:49 AM Tobias S. Josefowitz t.josefowitz@gmail.com wrote:
On Wed, Jun 16, 2021 at 11:08 PM Chris Angelico rosuav@gmail.com wrote:
Should host_to_ip be put completely back how it was (IPv4 only), or should it return IPv4 if available, IPv6 else?
In my opinion returning IPv6 if no IPv4 can be found would neither be something that even new users (i.e. people calling the method after that behaviour would have been introduced) would expect, or for that matter, desire. I suppose the proposed utility in behaving like this is in the case where some code blindly passing on the result to e.g. connect() or similar would magically and/or accidentally simply keep working with IPv6-only hostnames. I would think that that is not worth the confusion, surprise and wholly unexpected system states (in user programs never expecting this to happen).
Fair enough. The change is a very simple one. My recommendation is: Use host_to_ips (in the plural) for most purposes.
I think this is ready for master branch now. Last call for comments or objections.
Happy Eyeballs, if implemented, should probably be an option - it's a tradeoff between faster connections and more load. Might be worth actually pushing that one down in the stack a bit, maybe a Stdio or Protocols function that establishes a connection and returns it?
I would really like that.
Shouldn't be too hard. I'll just do the asynchronous version, but if a threaded version is wanted, that might be of value too.
That'll be a separate project, but I'll see about creating Stdio.establish_connection(name_or_ips) to do this.
ChrisA
Took me a couple of months to get around to making sure this was good, but there's now a Protocols.TCP.HappyEyeballs class for establishing connections.
It's currently promise-only, but a callback version would be easy enough to add if needed.
I haven't changed Protocols.HTTP to use this, will try to make more use of Happy Eyeballs in my own code before making that change. Also, not sure how much inconsistency between the sync, thread, and async versions is acceptable. Maybe this should be a feature of Protocols.HTTP.Promise only?
ChrisA