[Groonga-commit] droonga/fluent-plugin-droonga at 8d1c772 [master] Move applying input adapter plugins code to input adapter

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Dec 20 16:24:50 JST 2013


Kouhei Sutou	2013-12-20 16:24:50 +0900 (Fri, 20 Dec 2013)

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

  Message:
    Move applying input adapter plugins code to input adapter

  Modified files:
    lib/droonga/dispatcher.rb
    lib/droonga/input_adapter.rb

  Modified: lib/droonga/dispatcher.rb (+1 -16)
===================================================================
--- lib/droonga/dispatcher.rb    2013-12-20 16:23:50 +0900 (cac609e)
+++ lib/droonga/dispatcher.rb    2013-12-20 16:24:50 +0900 (f7eafb2)
@@ -22,7 +22,6 @@ require "droonga/distributor"
 require "droonga/catalog"
 require "droonga/collector"
 require "droonga/farm"
-require "droonga/input_message"
 
 module Droonga
   class Dispatcher
@@ -173,22 +172,8 @@ module Droonga
       route.is_a?(String) || route.is_a?(Hash)
     end
 
-    def apply_input_adapters(message)
-      adapted_message = message
-      loop do
-        input_message = InputMessage.new(adapted_message)
-        command = input_message.command
-        break unless @input_adapter.processable?(command)
-        @input_adapter.process(command, input_message)
-        new_command = input_message.command
-        adapted_message = input_message.adapted_message
-        break if command == new_command
-      end
-      adapted_message
-    end
-
     def process_input_message(message)
-      adapted_message = apply_input_adapters(message)
+      adapted_message = @input_adapter.adapt(message)
       @distributor.process(adapted_message["type"], adapted_message)
     end
 

  Modified: lib/droonga/input_adapter.rb (+13 -0)
===================================================================
--- lib/droonga/input_adapter.rb    2013-12-20 16:23:50 +0900 (0558b9f)
+++ lib/droonga/input_adapter.rb    2013-12-20 16:24:50 +0900 (100298b)
@@ -17,6 +17,7 @@
 
 require "droonga/pluggable"
 require "droonga/input_adapter_plugin"
+require "droonga/input_message"
 
 module Droonga
   class InputAdapter
@@ -27,6 +28,18 @@ module Droonga
       load_plugins(options[:plugins] || [])
     end
 
+    def adapt(message)
+      adapted_message = message
+      @plugins.each do |plugin|
+        input_message = InputMessage.new(adapted_message)
+        command = input_message.command
+        next unless plugin.processable?(command)
+        process(command, input_message)
+        adapted_message = input_message.adapted_message
+      end
+      adapted_message
+    end
+
     private
     def instantiate_plugin(name)
       InputAdapterPlugin.repository.instantiate(name, @dispatcher)
-------------- next part --------------
HTML����������������������������...
下載 



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