[Groonga-commit] droonga/fluent-plugin-droonga at 28a2032 [master] Enable proxy/adapter plugins to be configured in the catalog.

Back to archive index

Daijiro MORI null+****@clear*****
Sun Sep 8 18:10:02 JST 2013


Daijiro MORI	2013-09-08 18:10:02 +0900 (Sun, 08 Sep 2013)

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

  Message:
    Enable proxy/adapter plugins to be configured in the catalog.

  Modified files:
    lib/droonga/catalog.rb
    lib/droonga/engine.rb
    lib/droonga/executor.rb
    lib/droonga/proxy.rb
    lib/droonga/server.rb
    lib/droonga/worker.rb

  Modified: lib/droonga/catalog.rb (+4 -0)
===================================================================
--- lib/droonga/catalog.rb    2013-09-06 21:40:39 +0900 (3101697)
+++ lib/droonga/catalog.rb    2013-09-08 18:10:02 +0900 (9d2ab09)
@@ -50,6 +50,10 @@ module Droonga
       end
     end
 
+    def option(name)
+      @catalog["options"][name]
+    end
+
     def get_engines(name)
       device = @catalog["farms"][name]["device"]
       pattern = Regexp.new("^#{name}\.")

  Modified: lib/droonga/engine.rb (+0 -6)
===================================================================
--- lib/droonga/engine.rb    2013-09-06 21:40:39 +0900 (8b3570f)
+++ lib/droonga/engine.rb    2013-09-08 18:10:02 +0900 (636a4a8)
@@ -22,13 +22,11 @@ require "cool.io"
 require "droonga/server"
 require "droonga/worker"
 require "droonga/executor"
-require "droonga/adapter"
 
 module Droonga
   class Engine
     DEFAULT_OPTIONS = {
       :queue_name => "DroongaQueue",
-      :handlers   => ["proxy"],
       :n_workers  => 1,
       :with_server  => false
     }
@@ -53,10 +51,6 @@ module Droonga
         start_emitter
       else
         @executor = Executor.new(@options)
-        if @options[:proxy]
-          @executor.add_handler("proxy_message")
-          @executor.add_handler("adapter")
-        end
       end
     end
 

  Modified: lib/droonga/executor.rb (+3 -2)
===================================================================
--- lib/droonga/executor.rb    2013-09-06 21:40:39 +0900 (1f7f298)
+++ lib/droonga/executor.rb    2013-09-08 18:10:02 +0900 (29976de)
@@ -22,7 +22,6 @@ require "groonga"
 require "droonga/job_queue"
 require "droonga/handler_plugin"
 require "droonga/plugin"
-require "droonga/catalog"
 require "droonga/proxy"
 
 module Droonga
@@ -32,11 +31,12 @@ module Droonga
     def initialize(options={})
       @handlers = []
       @outputs = {}
+      @options = options
       @name = options[:name]
       @database_name = options[:database] || "droonga/db"
       @queue_name = options[:queue_name] || "DroongaQueue"
       Droonga::JobQueue.ensure_schema(@database_name, @queue_name)
-      @handler_names = options[:handlers] || ["proxy"]
+      @handler_names = options[:handlers]
       @pool_size = options[:n_workers]
 #     load_handlers
       Droonga::Plugin.load_all
@@ -217,6 +217,7 @@ module Droonga
       @handler_names.each do |handler_name|
         add_handler(handler_name)
       end
+      add_handler("proxy_message") if @options[:proxy]
     end
 
     def find_handler(command)

  Modified: lib/droonga/proxy.rb (+10 -0)
===================================================================
--- lib/droonga/proxy.rb    2013-09-06 21:40:39 +0900 (8c430a9)
+++ lib/droonga/proxy.rb    2013-09-08 18:10:02 +0900 (b0fc809)
@@ -17,6 +17,8 @@
 
 require 'tsort'
 require "droonga/handler"
+require "droonga/adapter"
+require "droonga/catalog"
 
 module Droonga
   class Proxy
@@ -34,6 +36,10 @@ module Droonga
       @collectors = {}
       @current_id = 0
       @local = Regexp.new("^#{@name}")
+      plugins = ["proxy", "adapter"] + (Droonga::catalog.option("plugins")||[])
+      plugins.each do |plugin|
+        @worker.add_handler(plugin)
+      end
     end
 
     def shutdown
@@ -257,6 +263,10 @@ module Droonga
 
       def handle(name, value)
         tasks = @inputs[name]
+        unless tasks
+          #TODO: result arrived before its query
+          return
+        end
         tasks.each do |task|
           task["n_of_inputs"] += 1 if name
           component = task["component"]

  Modified: lib/droonga/server.rb (+0 -4)
===================================================================
--- lib/droonga/server.rb    2013-09-06 21:40:39 +0900 (888894c)
+++ lib/droonga/server.rb    2013-09-08 18:10:02 +0900 (78b1596)
@@ -66,10 +66,6 @@ module Droonga
       super
       @message_input = config[:message_input]
       @executor = Executor.new(config)
-      if config[:proxy]
-        @executor.add_handler("proxy_message")
-        @executor.add_handler("adapter")
-      end
     end
 
     def before_run

  Modified: lib/droonga/worker.rb (+1 -1)
===================================================================
--- lib/droonga/worker.rb    2013-09-06 21:40:39 +0900 (1eec029)
+++ lib/droonga/worker.rb    2013-09-08 18:10:02 +0900 (ba5aa95)
@@ -22,7 +22,7 @@ module Droonga
     attr_reader :context, :envelope, :name
 
     def initialize
-      @executor = Executor.new(config)
+      @executor = Executor.new(config.merge(:proxy => false))
     end
 
     def run
-------------- next part --------------
HTML����������������������������...
Download 



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