Repository navigation
docs: Correct the socket_factory open() signature - #472
Draft
kinyoklion wants to merge 1 commit into
Draft
kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
The socket_factory docs said the factory must provide open(uri, timeout). The SDK hands the factory to http.rb as its socket class, and http.rb has always called it as open(host, port): the host and port to connect to, or the proxy's when a proxy is configured. A factory written to the documented signature would get a host name where it expected a URI and a port where it expected a timeout. Document the real signature, that the SDK performs TLS over the returned stream, and that the connect timeout applies to the call. Also note that data sources built with the DataSystem builders use their own socket_factory, not Config#socket_factory. The spec helper SocketFactoryFromHash had the same misleading parameter names and ignored the port it was given. It now maps host names to addresses and connects to the port the HTTP client passes in, so the specs that use it depend on that argument.
2 of 3 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
SDK-3369
Describe the solution you've provided
Config#socket_factorywas documented as requiringopen(uri, timeout). The SDK passes the factory to http.rb assocket_class, and http.rb calls it assocket_class.open(host, port). That is true on every http.rb version the gemspec allows (>= 4.4.0, < 7.0.0), and has been since the option was added in 6.0.0.A factory written to the documented signature gets a host name where it expects a URI, and a port where it expects a timeout. Depending on how it is written, it either:
NoMethodErroronuri.host; orThe second case is quiet: in a local check, events went to whatever server was on the factory's own port, and the SDK reported the send as successful.
Changes:
Config#socket_factorydocs now:open(host, port);Timeout.timeoutin 4.4.1, 5.3.1 and 6.0.4.LaunchDarkly::DataSystembuilders don't useConfig#socket_factory. Each builder has its ownsocket_factory, andbuild_http_configonly reads that.DataSourceBuilderCommon#socket_factorydocs: give the signature and point toConfig#socket_factory.SocketFactoryFromHash: it declaredopen(uri, timeout)and ignored its second argument, mapping host names to ports. It now maps host names to addresses and connects to the port it is given. The two specs that use it put the server port in the URI, so they depend on the port argument.Describe alternatives you've considered
Making the FDv2 builders fall back to
Config#socket_factory. That's a behavior change, so I left it out of this docs fix.Additional context
Testing:
spec/impl/event_sender_spec.rbandspec/ldclient_end_to_end_spec.rbpass on Ruby 3.2.3 with http.rb 6.0.4.can be automatically loaded by Bundler.require. That's local only: its inline Gemfile resolves against system gems, which here lackaws-sdk-dynamodb.Follow-up: ld-eventsource has the same
open(uri, timeout)wording (lib/ld-eventsource/client.rb:98).