You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by cu...@apache.org on 2010/10/08 23:06:15 UTC

svn commit: r1006019 - in /avro/trunk: CHANGES.txt lang/ruby/lib/avro/ipc.rb

Author: cutting
Date: Fri Oct  8 21:06:15 2010
New Revision: 1006019

URL: http://svn.apache.org/viewvc?rev=1006019&view=rev
Log:
AVRO-537.  Ruby: Reuse client connection for multiple requests.  Contributed by Gabor Torok.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/ruby/lib/avro/ipc.rb

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1006019&r1=1006018&r2=1006019&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Fri Oct  8 21:06:15 2010
@@ -31,6 +31,9 @@ Avro 1.4.1 (unreleased)
     AVRO-668. Java: Reduce object allocations while writing strings.
     (scottcarey)
 
+    AVRO-537. Ruby: Reuse client connection for multiple requests.
+    (Gabor Torok via cutting)
+
   BUG FIXES
 
     AVRO-666. Remove an extraneous pdb.set_trace() that crept into schema.py

Modified: avro/trunk/lang/ruby/lib/avro/ipc.rb
URL: http://svn.apache.org/viewvc/avro/trunk/lang/ruby/lib/avro/ipc.rb?rev=1006019&r1=1006018&r2=1006019&view=diff
==============================================================================
--- avro/trunk/lang/ruby/lib/avro/ipc.rb (original)
+++ avro/trunk/lang/ruby/lib/avro/ipc.rb Fri Oct  8 21:06:15 2010
@@ -14,6 +14,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+require "net/http"
+
 module Avro::IPC
 
   class AvroRemoteError < Avro::AvroError; end
@@ -521,14 +523,13 @@ module Avro::IPC
     def initialize(host, port)
       @host, @port = host, port
       @remote_name = "#{host}:#{port}"
+      @conn = Net::HTTP.start host, port
     end
 
     def transceive(message)
       writer = FramedWriter.new(StringIO.new)
       writer.write_framed_message(message)
-      resp = Net::HTTP.start(host, port) do |http|
-        http.post('/', writer.to_s, {'Content-Type' => 'avro/binary'})
-      end
+      resp = @conn.post('/', writer.to_s, {'Content-Type' => 'avro/binary'})
       FramedReader.new(StringIO.new(resp.body)).read_framed_message
     end
   end