[Groonga-commit] droonga/fluent-plugin-droonga at 7498cf9 [master] Make ProxyHandler an abstract class.

Back to archive index

Daijiro MORI null+****@clear*****
Fri Aug 16 23:12:38 JST 2013


Daijiro MORI	2013-08-16 23:12:38 +0900 (Fri, 16 Aug 2013)

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

  Message:
    Make ProxyHandler an abstract class.

  Modified files:
    lib/droonga/plugin/handler_proxy.rb
    lib/droonga/proxy.rb

  Modified: lib/droonga/plugin/handler_proxy.rb (+11 -20)
===================================================================
--- lib/droonga/plugin/handler_proxy.rb    2013-08-16 22:13:28 +0900 (cbf6f24)
+++ lib/droonga/plugin/handler_proxy.rb    2013-08-16 23:12:38 +0900 (5685ab1)
@@ -18,35 +18,26 @@
 require "droonga/handler"
 
 module Droonga
-  class ProxyHandler < Droonga::Handler
+  class BasicProxyHandler < Droonga::ProxyHandler
     Droonga::HandlerPlugin.register("proxy", self)
 
     command :proxy_search
-    def proxy_search(request, *arguments)
-      task = request["task"]
-      task["value"] = "dummy"
+    def proxy_search(request)
+      "dummy"
     end
 
     command :proxy_gather
-    def proxy_gather(request, *arguments)
-      task = request["task"]
-      name = request["name"]
-      value = request["value"]
-      component = task["component"]
-      task["value"] ||= {}
-      task["value"][name] ||= []
-      task["value"][name] << value
+    def proxy_gather(request)
+      request.flatten
     end
 
     command :proxy_reduce
-    def proxy_reduce(request, *arguments)
-      task = request["task"]
-      name = request["name"]
-      value = request["value"]
-      component = task["component"]
-      task["value"] ||= {}
-      task["value"][name] ||= []
-      task["value"][name] << value
+    def proxy_reduce(request)
+      a, b = request
+      a ||= {}
+      a[name] ||= []
+      a[name] << b
+      a
     end
   end
 end

  Modified: lib/droonga/proxy.rb (+12 -0)
===================================================================
--- lib/droonga/proxy.rb    2013-08-16 22:13:28 +0900 (3851ea5)
+++ lib/droonga/proxy.rb    2013-08-16 23:12:38 +0900 (02699d2)
@@ -290,4 +290,16 @@ module Droonga
       return true
     end
   end
+  class ProxyHandler < Droonga::Handler
+    attr_reader :task, :name, :components, :args
+    def handle(command, request, *arguments)
+      @task = request["task"]
+      @name = request["name"]
+      @component = @task["component"]
+      @args = @component["args"]
+      value0 = @task["value"]
+      value1 = request["value"]
+      @task["value"] = super(command, [value0, value1], *arguments)
+    end
+  end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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