-
Notifications
You must be signed in to change notification settings - Fork 23
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
Request timeout #40
Comments
👍 to @PlugIN73 question |
Consider Rack::Timeout (https://github.com/kch/rack-timeout) or another similar Rack based solution. If that doesn't work, I can work on building in a Weary::Middleware to accommodate. |
maybe add special dsl for this and pass to Net::HTTP? class GithubRepo < Weary::Client
domain "https://api.github.com"
open_timeout 1
read_timeout 1
get :get, "/repos/{user}/{repo}"
end I think it`s better use native ruby capabilities than add additional middlewares |
@jbmeerkat It's look great! |
@jbmeerkat Ideally, the solution would fit all the request adapters. It's not immediately clear to me what those two methods do when using Excon for example. Weary was built with the Rack middleware model expressly for this purpose. I'd much rather see something like: class GithubRepo < Weary::Client
use Weary::Middleware::Timeout, 1
end Or something to that end. If another middleware can accomplish the same goal, more power to it. What could happen is that the Weary Timeout middleware can just attach some data to the request env that the adapters can read from. The problem with dipping down into Net::HTTP directly is that it's not exactly clear what should happen when the TimeoutError is thrown -- how does Weary react to that? |
@mwunsch maybe something like this get :get, "/repos/{user}/{repo}" do |resource|
resource.on_timeout [] # or anything else what we need to return if request fails
end and if no |
I think like so:
|
@mwunsch I find Timeout middleware in your code. Does it work? Can we use such syntax:
? |
Once a Timeout middleware is built, it can be used in that way, yes. You can use Rack::Timeout and see if it accomplishes what you want. |
Hello! It's possible to configure request timeout?
For example - http://www.ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-read_timeout-3D
The text was updated successfully, but these errors were encountered: