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

Added configurable connection timeouts #187

Merged
merged 1 commit into from
Mar 29, 2015
Merged

Conversation

zanker
Copy link
Contributor

@zanker zanker commented Mar 26, 2015

This is mildly crazy. Basically this adds three sets of timeouts

Null, which is just what there is today (nothing)
Per operation, which is what you see in things like Net::HTTP, Excon where the timeout is per operation
Global, which sets an allocation of how much time can be used and uses it up as the request goes. Ensuring a request can never run longer than the set time.

Getting DNS to have a customizable timeout is awful though, which is why there's a lot of extra code for doing connect (mostly cribbed from Tony's code). My inclination, would be to just wrap it in Timeout.timeout since that can be done more safely than relying on all the Ruby internals to handle the DNS/open timeouts properly. And it's safer, any thoughts on that?

@zanker zanker force-pushed the timeouts branch 2 times, most recently from a830eee to 15bf359 Compare March 26, 2015 22:12
@ixti
Copy link
Member

ixti commented Mar 27, 2015

I guess this will close #160

@zanker
Copy link
Contributor Author

zanker commented Mar 27, 2015

Yup! This is kind of a complicated set of changes though. See any issues with it?

@sferik
Copy link
Contributor

sferik commented Mar 27, 2015

@zanker It looks like the “HTTP::Client timeouts with a per operation timeout connection of 0 times out” specs are failing in CI.

@zanker
Copy link
Contributor Author

zanker commented Mar 27, 2015

Haha awesome. I can make it go green locally, but I expect the CI servers are running fast enough that it immediately connects, or maybe they do something strange.

I don't have a good way of testing connection latency. Since it's "connected" before I call accept on a server, and if the servers not up it just fails immediately. Let me try setting a float timeout and see if that hacks it into working.

@tarcieri
Copy link
Member

Timeouts, especially ones related to I/O so they can't simply be mocked, have been rather troublesome for me to test in things like Celluloid. Short of using something like rspec-retry and rerunning the test until it passes, I'm not sure I have any good advice.

On Celluloid we use a "quantum" of 50ms for all timer tests.

@zanker
Copy link
Contributor Author

zanker commented Mar 28, 2015

:(

I stripped that test then

@sferik sferik modified the milestone: v0.8.0 Mar 28, 2015
@tarcieri
Copy link
Member

Seems there are still 3 failing tests... and a rebase is needed

@zanker
Copy link
Contributor Author

zanker commented Mar 29, 2015

Think something got a bit messed up from merge conflicts. Should go green now

@ixti
Copy link
Member

ixti commented Mar 29, 2015

Awesome!!! 👏

ixti added a commit that referenced this pull request Mar 29, 2015
Added configurable connection timeouts
@ixti ixti merged commit 8d40d8b into httprb:master Mar 29, 2015
@tarcieri
Copy link
Member

Released as 0.8.0.pre4

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.

4 participants