Commits

Sean Cribbs  committed 3b643ef

Use persistent connections in Excon backend.

  • Participants
  • Parent commits 0e46e15

Comments (0)

Files changed (1)

File riak-client/lib/riak/client/excon_backend.rb

 
       private
       def perform(method, uri, headers, expect, data=nil, &block)
-        params = {:headers => RequestHeaders.new(headers)}
+        params = {
+          :method => method,
+          :headers => RequestHeaders.new(headers),
+          :path => uri.path
+        }
+        params[:query] = uri.query if uri.query
         params[:body] = data if [:put,:post].include?(method)
         params[:idempotent] = (method != :post)
-        response = Excon.send(method, uri.to_s, params, &block)
+
+        response = connection.request(params, &block)
         if valid_response?(expect, response.status)
           response_headers.initialize_http_header(response.headers)
           result = {:headers => response_headers.to_hash, :code => response.status}
         end
       end
 
+      def connection
+        @connection ||= Excon::Connection.new(root_uri.to_s)
+      end
+
       # Excon uses for..in syntax to emit headers, but we still want
       # to split them on 8KB boundaries.
       class RequestHeaders < Riak::Util::Headers