[Groonga-commit] droonga/droonga-engine at d72e1f2 [master] worker: don't use buffer

アーカイブの一覧に戻る

Kouhei Sutou null+****@clear*****
Mon Jul 21 11:27:55 JST 2014


Kouhei Sutou	2014-07-21 11:27:55 +0900 (Mon, 21 Jul 2014)

  New Revision: d72e1f2b5e6834bb82c27b48a966aa6f63c9f0dc
  https://github.com/droonga/droonga-engine/commit/d72e1f2b5e6834bb82c27b48a966aa6f63c9f0dc

  Message:
    worker: don't use buffer
    
    Because workers handle only volatile messages.

  Modified files:
    lib/droonga/engine_state.rb
    lib/droonga/fluent_message_sender.rb
    lib/droonga/forwarder.rb

  Modified: lib/droonga/engine_state.rb (+1 -1)
===================================================================
--- lib/droonga/engine_state.rb    2014-07-21 11:05:47 +0900 (01e02f8)
+++ lib/droonga/engine_state.rb    2014-07-21 11:27:55 +0900 (094e339)
@@ -40,7 +40,7 @@ module Droonga
       @internal_name = internal_name
       @sessions = {}
       @current_id = 0
-      @forwarder = Forwarder.new(@loop)
+      @forwarder = Forwarder.new(@loop, :buffering => true)
       @forwarder.resume
       @replier = Replier.new(@forwarder)
       @on_ready = nil

  Modified: lib/droonga/fluent_message_sender.rb (+10 -4)
===================================================================
--- lib/droonga/fluent_message_sender.rb    2014-07-21 11:05:47 +0900 (5d43c14)
+++ lib/droonga/fluent_message_sender.rb    2014-07-21 11:27:55 +0900 (8031fa8)
@@ -29,11 +29,12 @@ module Droonga
   class FluentMessageSender
     include Loggable
 
-    def initialize(loop, host, port)
+    def initialize(loop, host, port, options={})
       @loop = loop
       @host = host
       @port = port
       @socket = nil
+      @buffering = options[:buffering]
     end
 
     def start
@@ -56,6 +57,7 @@ module Droonga
     end
 
     def resume
+      return unless @buffering
       connect unless connected?
       @socket.resume
     end
@@ -82,9 +84,13 @@ module Droonga
         @socket = nil
       end
 
-      data_directory = Path.buffer + "#{@host}:#{@port}"
-      FileUtils.mkdir_p(data_directory.to_s)
-      @socket = BufferedTCPSocket.connect(@host, @port, data_directory)
+      if @buffering
+        data_directory = Path.buffer + "#{@host}:#{@port}"
+        FileUtils.mkdir_p(data_directory.to_s)
+        @socket = BufferedTCPSocket.connect(@host, @port, data_directory)
+      else
+        @socket = Coolio::TCPSocket.connect(@host, @port)
+      end
       @socket.on_write_complete do
         log_write_complete.call
       end

  Modified: lib/droonga/forwarder.rb (+6 -2)
===================================================================
--- lib/droonga/forwarder.rb    2014-07-21 11:05:47 +0900 (58cf53e)
+++ lib/droonga/forwarder.rb    2014-07-21 11:27:55 +0900 (01d11c7)
@@ -24,8 +24,9 @@ module Droonga
   class Forwarder
     include Loggable
 
-    def initialize(loop)
+    def initialize(loop, options={})
       @loop = loop
+      @buffering = options[:buffering]
       @senders = {}
     end
 
@@ -131,7 +132,10 @@ module Droonga
     end
 
     def create_sender(host, port)
-      sender = FluentMessageSender.new(@loop, host, port)
+      options = {
+        :buffering => @buffering,
+      }
+      sender = FluentMessageSender.new(@loop, host, port, options)
       sender.start
       sender
     end
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る