Class: Sunspot::SessionProxy::Retry5xxSessionProxy::RetryHandler
- Inherits:
-
Object
- Object
- Sunspot::SessionProxy::Retry5xxSessionProxy::RetryHandler
- Defined in:
- lib/sunspot/session_proxy/retry_5xx_session_proxy.rb
Instance Attribute Summary collapse
-
#search_session ⇒ Object
readonly
Returns the value of attribute search_session.
Instance Method Summary collapse
-
#initialize(search_session) ⇒ RetryHandler
constructor
A new instance of RetryHandler.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(search_session) ⇒ RetryHandler
Returns a new instance of RetryHandler.
10 11 12 |
# File 'lib/sunspot/session_proxy/retry_5xx_session_proxy.rb', line 10 def initialize(search_session) @search_session = search_session end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sunspot/session_proxy/retry_5xx_session_proxy.rb', line 14 def method_missing(m, *args, &block) retry_count = 1 begin search_session.send(m, *args, &block) rescue Errno::ECONNRESET => e if retry_count > 0 $stderr.puts "Error - #{e.[/^.*$/]} - retrying..." retry_count -= 1 retry else $stderr.puts "Error - #{e.[/^.*$/]} - ignoring..." end rescue RSolr::Error::Http => e if (500..599).include?(e.response[:status].to_i) if retry_count > 0 $stderr.puts "Error - #{e.[/^.*$/]} - retrying..." retry_count -= 1 retry else $stderr.puts "Error - #{e.[/^.*$/]} - ignoring..." e.response end else raise e end end end |
Instance Attribute Details
#search_session ⇒ Object (readonly)
Returns the value of attribute search_session.
8 9 10 |
# File 'lib/sunspot/session_proxy/retry_5xx_session_proxy.rb', line 8 def search_session @search_session end |