[Groonga-commit] droonga/fluent-plugin-droonga at f517e4a [master] adapter groonga: don't use add_route feature to apply output adapter

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 31 18:18:29 JST 2014


Kouhei Sutou	2014-01-31 18:18:29 +0900 (Fri, 31 Jan 2014)

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

  Message:
    adapter groonga: don't use add_route feature to apply output adapter
    
    We remove all add_route related codes! Now, we can remove "via" in
    message! Viva!

  Modified files:
    lib/droonga/input_message.rb
    lib/droonga/output_adapter.rb
    lib/droonga/plugin/input_adapter/groonga.rb
    lib/droonga/plugin/output_adapter/groonga.rb
    lib/fluent/plugin/out_droonga.rb

  Modified: lib/droonga/input_message.rb (+4 -4)
===================================================================
--- lib/droonga/input_message.rb    2014-01-31 18:15:51 +0900 (9893b3e)
+++ lib/droonga/input_message.rb    2014-01-31 18:18:29 +0900 (8fde6bb)
@@ -28,10 +28,6 @@ module Droonga
       @raw_message
     end
 
-    def add_route(route)
-      @raw_message["via"].push(route)
-    end
-
     def body
       @raw_message["body"]
     end
@@ -45,6 +41,10 @@ module Droonga
     end
 
     def command=(command)
+      original_command = @raw_message["type"]
+      return if original_command == command
+      @raw_message["originalTypes"] ||= []
+      @raw_message["originalTypes"] << original_command
       @raw_message["type"] = command
     end
   end

  Modified: lib/droonga/output_adapter.rb (+6 -17)
===================================================================
--- lib/droonga/output_adapter.rb    2014-01-31 18:15:51 +0900 (cb364f8)
+++ lib/droonga/output_adapter.rb    2014-01-31 18:18:29 +0900 (e286975)
@@ -37,23 +37,12 @@ module Droonga
       adapt_errors(output_message)
       adapted_message = output_message.adapted_message
 
-      if message["via"].empty?
-        @plugins.each do |plugin|
-          plugin.class.commands.each do |command|
-            next unless command.match?(adapted_message)
-            output_message = OutputMessage.new(adapted_message)
-            plugin.process(command, output_message)
-            adapted_message = output_message.adapted_message
-          end
-        end
-      else
-        message["via"].reverse_each do |command|
-          @plugins.each do |plugin|
-            next unless plugin.processable?(command)
-            output_message = OutputMessage.new(adapted_message)
-            process(command, output_message)
-            adapted_message = output_message.adapted_message
-          end
+      @plugins.each do |plugin|
+        plugin.class.commands.each do |command|
+          next unless command.match?(adapted_message)
+          output_message = OutputMessage.new(adapted_message)
+          plugin.process(command, output_message)
+          adapted_message = output_message.adapted_message
         end
       end
 

  Modified: lib/droonga/plugin/input_adapter/groonga.rb (+0 -1)
===================================================================
--- lib/droonga/plugin/input_adapter/groonga.rb    2014-01-31 18:15:51 +0900 (8ad665f)
+++ lib/droonga/plugin/input_adapter/groonga.rb    2014-01-31 18:18:29 +0900 (4996e0b)
@@ -24,7 +24,6 @@ module Droonga
       command = Select.new
       select_request = input_message.body
       search_request = command.convert(select_request)
-      input_message.add_route("select_response")
       input_message.command = "search"
       input_message.body = search_request
     end

  Modified: lib/droonga/plugin/output_adapter/groonga.rb (+3 -2)
===================================================================
--- lib/droonga/plugin/output_adapter/groonga.rb    2014-01-31 18:15:51 +0900 (25032c2)
+++ lib/droonga/plugin/output_adapter/groonga.rb    2014-01-31 18:18:29 +0900 (ebf28f7)
@@ -19,8 +19,9 @@ module Droonga
   class GroongaOutputAdapter < Droonga::OutputAdapterPlugin
     repository.register("groonga", self)
 
-    command :select_response
-    def select_response(output_message)
+    command :convert_select,
+            :patterns => [["originalTypes", :include?, "select"]]
+    def convert_select(output_message)
       command = Select.new
       output_message.body = command.convert(output_message.body)
     end

  Modified: lib/fluent/plugin/out_droonga.rb (+0 -1)
===================================================================
--- lib/fluent/plugin/out_droonga.rb    2014-01-31 18:15:51 +0900 (6ba3c99)
+++ lib/fluent/plugin/out_droonga.rb    2014-01-31 18:18:29 +0900 (cad8f79)
@@ -60,7 +60,6 @@ module Fluent
           "body" => record
         }
       end
-      message["via"] ||= []
       reply_to = message["replyTo"]
       if reply_to.is_a? String
         message["replyTo"] = {
-------------- next part --------------
HTML����������������������������...
Download 



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