Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add support for configurable timeouts

  • Loading branch information...
commit 2702395acbd939615e7280db723f28ae598d1f15 1 parent 5e0d54d
Mike Perham mperham authored

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 lib/rsolr-async.rb
8 lib/rsolr-async.rb
@@ -40,12 +40,16 @@ def connection path
40 40 REQUEST_CLASS.new("#{@uri.to_s}#{path}")
41 41 end
42 42
  43 + def timeout
  44 + opts[:timeout] || 5
  45 + end
  46 +
43 47 def get path, params={}
44 48 # this yield/resume business is complicated by em-http's mocking support which
45 49 # yields to the callback immediately rather than from another fiber.
46 50 yielding = true
47 51 fiber = Fiber.current
48   - http_response = self.connection(path).get :query => params, :timeout => 5
  52 + http_response = self.connection(path).get :query => params, :timeout => timeout
49 53 http_response.callback do
50 54 yielding = false
51 55 fiber.resume if Fiber.current != fiber
@@ -61,7 +65,7 @@ def get path, params={}
61 65 def post path, data, params={}, headers={}
62 66 yielding = true
63 67 fiber = Fiber.current
64   - http_response = self.connection(path).post :query => params, :body => data, :head => headers, :timeout => 5
  68 + http_response = self.connection(path).post :query => params, :body => data, :head => headers, :timeout => timeout
65 69 http_response.callback do
66 70 yielding = false
67 71 fiber.resume if Fiber.current != fiber

0 comments on commit 2702395

Please sign in to comment.
Something went wrong with that request. Please try again.