[Groonga-commit] droonga/droonga-client-ruby at ee021d7 [master] Move Connection::DroongaProtocol under Client

Back to archive index

Yoji Shidara null+****@clear*****
Wed Sep 11 15:29:28 JST 2013


Yoji Shidara	2013-09-11 15:29:28 +0900 (Wed, 11 Sep 2013)

  New Revision: ee021d7374b2c6a90e51727a9f1f339c8484c9ed
  https://github.com/droonga/droonga-client-ruby/commit/ee021d7374b2c6a90e51727a9f1f339c8484c9ed

  Message:
    Move Connection::DroongaProtocol under Client

  Added files:
    lib/droonga/client/connection/droonga_protocol.rb
  Removed files:
    lib/droonga/connection/droonga_protocol.rb
  Modified files:
    lib/droonga/client.rb

  Modified: lib/droonga/client.rb (+1 -1)
===================================================================
--- lib/droonga/client.rb    2013-09-11 15:25:29 +0900 (c5a53fa)
+++ lib/droonga/client.rb    2013-09-11 15:29:28 +0900 (b5ffaca)
@@ -20,7 +20,7 @@ require "msgpack"
 require "fluent-logger"
 
 require "droonga/client/version"
-require "droonga/connection/droonga_protocol"
+require "droonga/client/connection/droonga_protocol"
 
 module Droonga
   class Client

  Added: lib/droonga/client/connection/droonga_protocol.rb (+99 -0) 100644
===================================================================
--- /dev/null
+++ lib/droonga/client/connection/droonga_protocol.rb    2013-09-11 15:29:28 +0900 (ed7e743)
@@ -0,0 +1,99 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2013 droonga project
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1 as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+module Droonga
+  class Client
+    module Connection
+      class DroongaProtocol
+        def initialize(options={})
+          default_options = {
+            :tag     => "droonga",
+            :host    => "127.0.0.1",
+            :port    => 24224,
+            :timeout => 5
+          }
+          options = default_options.merge(options)
+          @logger = Fluent::Logger::FluentLogger.new(options.delete(:tag),
+                                                     options)
+          @timeout = options[:timeout]
+        end
+
+        def search(body)
+          envelope = {
+          "id"         => Time.now.to_f.to_s,
+          "date"       => Time.now,
+          "statusCode" => 200,
+          "type"       => "search",
+          "body"       => body,
+          }
+          send_receive(envelope)
+        end
+
+        def send_receive(envelope)
+          receiver = Receiver.new
+          begin
+            envelope = envelope.dup
+            envelope["replyTo"] = "#{receiver.host}:#{receiver.port}/droonga"
+            @logger.post("message", envelope)
+            receiver.receive(:timeout => @timeout)
+          ensure
+            receiver.close
+          end
+        end
+
+        class Receiver
+          def initialize(options={})
+            default_options = {
+              :host => "0.0.0.0",
+              :port => 0,
+            }
+            options = default_options.merge(options)
+            @socket = TCPServer.new(options[:host], options[:port])
+          end
+
+          def close
+            @socket.close
+          end
+
+          def host
+            @socket.addr[3]
+          end
+
+          def port
+            @socket.addr[1]
+          end
+
+          def receive(options={})
+            if IO.select([@socket], nil, nil, options[:timeout])
+              client =****@socke*****
+              response = nil
+              unpacker = MessagePack::Unpacker.new(client)
+              unpacker.each do |object|
+                response = object
+                break
+              end
+              client.close
+              response
+            else
+              nil
+            end
+          end
+        end
+      end
+    end
+  end
+end

  Deleted: lib/droonga/connection/droonga_protocol.rb (+0 -97) 100644
===================================================================
--- lib/droonga/connection/droonga_protocol.rb    2013-09-11 15:25:29 +0900 (71aeba3)
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2013 droonga project
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License version 2.1 as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-module Droonga
-  module Connection
-    class DroongaProtocol
-      def initialize(options={})
-        default_options = {
-          :tag     => "droonga",
-          :host    => "127.0.0.1",
-          :port    => 24224,
-          :timeout => 5
-        }
-        options = default_options.merge(options)
-        @logger = Fluent::Logger::FluentLogger.new(options.delete(:tag),
-                                                   options)
-        @timeout = options[:timeout]
-      end
-
-      def search(body)
-        envelope = {
-          "id"         => Time.now.to_f.to_s,
-          "date"       => Time.now,
-          "statusCode" => 200,
-          "type"       => "search",
-          "body"       => body,
-        }
-        send_receive(envelope)
-      end
-
-      def send_receive(envelope)
-        receiver = Receiver.new
-        begin
-          envelope = envelope.dup
-          envelope["replyTo"] = "#{receiver.host}:#{receiver.port}/droonga"
-          @logger.post("message", envelope)
-          receiver.receive(:timeout => @timeout)
-        ensure
-          receiver.close
-        end
-      end
-
-      class Receiver
-        def initialize(options={})
-          default_options = {
-            :host => "0.0.0.0",
-            :port => 0,
-          }
-          options = default_options.merge(options)
-          @socket = TCPServer.new(options[:host], options[:port])
-        end
-
-        def close
-          @socket.close
-        end
-
-        def host
-          @socket.addr[3]
-        end
-
-        def port
-          @socket.addr[1]
-        end
-
-        def receive(options={})
-          if IO.select([@socket], nil, nil, options[:timeout])
-            client =****@socke*****
-            response = nil
-            unpacker = MessagePack::Unpacker.new(client)
-            unpacker.each do |object|
-              response = object
-              break
-            end
-            client.close
-            response
-          else
-            nil
-          end
-        end
-      end
-    end
-  end
-end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index