Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use better http-rb global timeout value #28

Merged
merged 3 commits into from
Oct 12, 2021

Conversation

jrochkind
Copy link
Contributor

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 of 3 would turn into HTTP.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.

jrochkind and others added 3 commits October 11, 2021 13:01
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](https://github.com/httprb/http/wiki/Timeouts), 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 of `3` would turn into `HTTP.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.
Copy link
Member

@iMacTia iMacTia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out and fixing it @jrochkind 🎉

@iMacTia iMacTia merged commit 449327d into lostisland:master Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants