Open midnight-wonderer opened 6 days ago
This addresses https://github.com/httprb/http/issues/739.
Happy Eyeballs landed in Ruby for quite some time. :tada: https://bugs.ruby-lang.org/issues/20108
However, it does not reach HTTP.rb yet. This is because HTTP.rb uses TCPSocket.open by default.
open
new
TCPSocket
In order to take advantage of the new feature. I alias default_socket_class to Socket.tcp so the connection logic will be handled by the Ruby layer of Socket.
default_socket_class
Socket.tcp
Socket
For your information Socket.tcp has a lot of features beyond Happy Eyeballs. For example, it supports connect_timeout natively. What to do with https://github.com/httprb/http/blob/db6863ab48fdd77178078b3128a9db3d0ad6069a/lib/http/timeout/global.rb#L24 needs more discussions. This is just one aspect of it.
connect_timeout
Nevertheless, this baby step would introduce minimal breaking changes. (or any changes at all) Providing more robust connections.
Overview
This addresses https://github.com/httprb/http/issues/739.
Happy Eyeballs landed in Ruby for quite some time. :tada: https://bugs.ruby-lang.org/issues/20108
However, it does not reach HTTP.rb yet. This is because HTTP.rb uses TCPSocket.open by default.
Source traces
open
was implemented in the IO class as an alias tonew
.https://github.com/ruby/ruby/blob/37a16c7812f5b7e6faa762b927e9f04065cc495a/io.c#L8124
TCPSocket
, it is bound directly to the c source code.https://github.com/ruby/ruby/blob/6deeec5d459ecff5ec4628523b14ac7379fd942e/ext/socket/tcpsocket.c#L54
https://github.com/ruby/ruby/commit/9ec342e07df6aa5e2c2e9003517753a2f1b508fd
A baby step
In order to take advantage of the new feature. I alias
default_socket_class
toSocket.tcp
so the connection logic will be handled by the Ruby layer ofSocket
.Rough edges
For your information
Socket.tcp
has a lot of features beyond Happy Eyeballs. For example, it supportsconnect_timeout
natively. What to do with https://github.com/httprb/http/blob/db6863ab48fdd77178078b3128a9db3d0ad6069a/lib/http/timeout/global.rb#L24 needs more discussions. This is just one aspect of it.Nevertheless, this baby step would introduce minimal breaking changes. (or any changes at all) Providing more robust connections.