Class: Elastictastic::ExconAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/elastictastic/adapter.rb

Instance Method Summary collapse

Methods inherited from Adapter

[], #initialize

Methods included from TransportMethods

#delete, #get, #head, #post, #put

Constructor Details

This class inherits a constructor from Elastictastic::Adapter

Instance Method Details

#request(method, path, body = nil) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/elastictastic/adapter.rb', line 55

def request(method, path, body = nil)
  retried = false
  begin
    response = connection.request(
      :body => body, :method => method, :path => path
    )
    Response.new(response.status, response.headers, response.body)
  rescue Excon::Errors::SocketError => e
    case e.socket_error
    when Errno::EPIPE, Errno::ECONNRESET
      if !retried
        connection.reset
        retried = true
        retry
      end
    end
    raise
  end
rescue Excon::Errors::Error => e
  connection.reset
  raise ConnectionFailed, e
end