Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for configurable timeouts

  • Loading branch information...
commit 2702395acbd939615e7280db723f28ae598d1f15 1 parent 5e0d54d
@mperham mperham authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/rsolr-async.rb
View
8 lib/rsolr-async.rb
@@ -40,12 +40,16 @@ def connection path
REQUEST_CLASS.new("#{@uri.to_s}#{path}")
end
+ def timeout
+ opts[:timeout] || 5
+ end
+
def get path, params={}
# this yield/resume business is complicated by em-http's mocking support which
# yields to the callback immediately rather than from another fiber.
yielding = true
fiber = Fiber.current
- http_response = self.connection(path).get :query => params, :timeout => 5
+ http_response = self.connection(path).get :query => params, :timeout => timeout
http_response.callback do
yielding = false
fiber.resume if Fiber.current != fiber
@@ -61,7 +65,7 @@ def get path, params={}
def post path, data, params={}, headers={}
yielding = true
fiber = Fiber.current
- http_response = self.connection(path).post :query => params, :body => data, :head => headers, :timeout => 5
+ http_response = self.connection(path).post :query => params, :body => data, :head => headers, :timeout => timeout
http_response.callback do
yielding = false
fiber.resume if Fiber.current != fiber
Please sign in to comment.
Something went wrong with that request. Please try again.