class NoBrainer::QueryRunner::Reconnect
Public Instance Methods
call(env)
click to toggle source
# File lib/no_brainer/query_runner/reconnect.rb, line 2 def call(env) @runner.call(env) rescue StandardError => e NoBrainer.disconnect if is_connection_error_exception?(e) raise end
Private Instance Methods
is_connection_error_exception?(e)
click to toggle source
# File lib/no_brainer/query_runner/reconnect.rb, line 11 def is_connection_error_exception?(e) case e when Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::EPIPE, Errno::ECONNRESET, Errno::ETIMEDOUT, IOError true when RethinkDB::RqlError e.message =~ /lost contact/ || e.message =~ /(P|p)rimary .* not available/|| e.message =~ /Connection.*closed/ || e.message =~ /Connection.*refused/ else false end end