Cache adapter connections (attempt 1) #1061
Draft
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.
This was an attempt to steps 2, 4, and 5 of #1024
(items copied below, since #1024 has changed)
ConnectionOptions
to Env as:connection
key.RequestOptions
toConnectionOptions
::proxy, :bind, :timeout, :read_timeout, :open_timeout, :write_timeout
Adapter#initialize
to save the connection if it can:I started by caching the connection first, and then worrying about how to include the connection options. But, I realized I need a way to merge the connection options with request options, so that something like this will work as expected:
I think this approach was backwards. I should setup
ConnectionOptions
and merge it withRequestOptions
at the right time, with whateverproxy
changes are needed, before worrying about caching the HTTP object.I'm keeping this PR around as an example, but I'll probably end up rewriting or cherry-picking these commits into something else later.