Use better http-rb global timeout value #28
Merged
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.
Since http-rb 4.0, the http-rb gem has supported a better global timeout as
timeout(seconds)
.httprb/http#446
As the http-rb wiki explains, using eg
timeout(3)
means that 3 seconds is an upper bound for the entire HTTP call.The old way of doing things, before this PR, setting a faraday
timeout
value of3
would turn intoHTTP.timeout(connect: 3, write: 3, read: 3)
, which would mean the whole HTTP call could actually take up to 9 seconds: 3 for open, 3 for write, another 3 for read.The new way is better semantics for a single faraday
timeout
option. It's been supported since http-rb 4.0, and this Faraday adapter doesn't support any earlier http-rb.It makes sense to change to use the new better way.
The existing functionality is not tested here; and I couldn't figure out any good way to test it. Mocking http-rb raising a timeout error would not test this functionality of passing in timeout confiuration appropriately to http-rb. I spent some time on it, but couldn't figure out any good way to test, sorry. This is not a reduction in test coverage, it already wasn't tested.