[Groonga-commit] droonga/fluent-plugin-droonga at ee1ab40 [master] Move local message processing code to Dispatcher from Session

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 24 16:40:51 JST 2013


Kouhei Sutou	2013-12-24 16:40:51 +0900 (Tue, 24 Dec 2013)

  New Revision: ee1ab40f53a72da2e25a6663c1dfbc0f156e5a32
  https://github.com/droonga/fluent-plugin-droonga/commit/ee1ab40f53a72da2e25a6663c1dfbc0f156e5a32

  Message:
    Move local message processing code to Dispatcher from Session

  Modified files:
    lib/droonga/dispatcher.rb
    lib/droonga/farm.rb
    lib/droonga/partition.rb
    lib/droonga/processor.rb
    lib/droonga/session.rb

  Modified: lib/droonga/dispatcher.rb (+15 -5)
===================================================================
--- lib/droonga/dispatcher.rb    2013-12-24 16:31:08 +0900 (b83174d)
+++ lib/droonga/dispatcher.rb    2013-12-24 16:40:51 +0900 (3796dae)
@@ -138,11 +138,21 @@ module Droonga
       end
     end
 
-    # TODO: Use more meaningful name
-    def process_in_farm(route, message, type, synchronous)
-      # TODO: validate route is farm path
-      message =****@messa*****("body" => message, "type" => type)
-      @farm.process(route, message, synchronous)
+    def process_local_message(local_message)
+      task = local_message["task"]
+      partition_name = task["route"]
+      component = task["component"]
+      command = component["command"]
+      descendants = {}
+      component["descendants"].each do |name, routes|
+        descendants[name] = routes.collect do |route|
+          farm_path(route)
+        end
+      end
+      local_message["descendants"] = descendants
+      farm_message =****@messa*****("body" => local_message,
+                                    "type" => command)
+      @farm.process(partition_name, farm_message)
     end
 
     def generate_id

  Modified: lib/droonga/farm.rb (+2 -2)
===================================================================
--- lib/droonga/farm.rb    2013-12-24 16:31:08 +0900 (b8b7bb0)
+++ lib/droonga/farm.rb    2013-12-24 16:40:51 +0900 (dec6182)
@@ -40,8 +40,8 @@ module Droonga
       end
     end
 
-    def process(partition_name, message, synchronous)
-      @partitions[partition_name].process(message, synchronous)
+    def process(partition_name, message)
+      @partitions[partition_name].process(message)
     end
   end
 end

  Modified: lib/droonga/partition.rb (+2 -2)
===================================================================
--- lib/droonga/partition.rb    2013-12-24 16:31:08 +0900 (2a5d43b)
+++ lib/droonga/partition.rb    2013-12-24 16:40:51 +0900 (eaddb00)
@@ -55,9 +55,9 @@ module Droonga
       $log.trace("partition: shutdown: done")
     end
 
-    def process(message, synchronous=nil)
+    def process(message)
       $log.trace("partition: process: start")
-      @processor.process(message, synchronous)
+      @processor.process(message)
       $log.trace("partition: process: done")
     end
 

  Modified: lib/droonga/processor.rb (+2 -4)
===================================================================
--- lib/droonga/processor.rb    2013-12-24 16:31:08 +0900 (91d4d02)
+++ lib/droonga/processor.rb    2013-12-24 16:40:51 +0900 (3c3118f)
@@ -37,14 +37,12 @@ module Droonga
       $log.trace("#{log_tag}: shutdown: done")
     end
 
-    def process(message, synchronous=nil)
+    def process(message)
       $log.trace("#{log_tag}: process: start")
       command = message["type"]
       if****@handl*****?(command)
         $log.trace("#{log_tag}: process: handlable: #{command}")
-        if synchronous.nil?
-          synchronous =****@handl*****_synchronous?(command)
-        end
+        synchronous =****@handl*****_synchronous?(command)
         if @n_workers.zero? or synchronous
           @handler.process(message)
         else

  Modified: lib/droonga/session.rb (+4 -15)
===================================================================
--- lib/droonga/session.rb    2013-12-24 16:31:08 +0900 (dd6317c)
+++ lib/droonga/session.rb    2013-12-24 16:40:51 +0900 (5b7e0d7)
@@ -32,22 +32,11 @@ module Droonga
     def start
       tasks = @inputs[nil]
       tasks.each do |task|
-        component = task["component"]
-        type = component["type"]
-        command = component["command"]
-        synchronous = nil
-        descendants = {}
-        component["descendants"].each do |name, routes|
-          descendants[name] = routes.map do |route|
-            @dispatcher.farm_path(route)
-          end
-        end
-        message = {
-          "id"          => @id,
-          "task"        => task,
-          "descendants" => descendants
+        local_message = {
+          "id"   => @id,
+          "task" => task,
         }
-        @dispatcher.process_in_farm(task["route"], message, command, synchronous)
+        @dispatcher.process_local_message(local_message)
         @n_dones += 1
       end
     end
-------------- next part --------------
HTML����������������������������...
下载 



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