[Groonga-commit] droonga/fluent-plugin-droonga at 38ecccd [master] Output error infromation with the database name

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Jan 27 17:15:50 JST 2014


YUKI Hiroshi	2014-01-27 17:15:50 +0900 (Mon, 27 Jan 2014)

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

  Message:
    Output error infromation with the database name

  Modified files:
    lib/droonga/handler_messenger.rb
    lib/droonga/plugin/distributor/crud.rb

  Modified: lib/droonga/handler_messenger.rb (+26 -1)
===================================================================
--- lib/droonga/handler_messenger.rb    2014-01-27 17:20:28 +0900 (a8ae795)
+++ lib/droonga/handler_messenger.rb    2014-01-27 17:15:50 +0900 (182408f)
@@ -18,12 +18,15 @@ require "droonga/forwarder"
 
 module Droonga
   class HandlerMessenger
+    attr_reader :database_name
+
     def initialize(forwarder, message, options={})
       @forwarder = forwarder
       @message = message
       @options = options
       @replier = Replier.new(@forwarder)
       @dispatcher = @options[:dispatcher]
+      @database_name = options[:database]
     end
 
     def emit(value)
@@ -54,10 +57,32 @@ module Droonga
     def error(status_code, body)
       descendants =****@messa*****
       raw_message =****@messa*****
-      unless raw_message["replyTo"].nil?
+      if descendants.empty?
+        return if raw_message["replyTo"].nil?
         response = raw_message.merge("statusCode" => status_code,
                                      "body" => body)
         @replier.reply(response)
+      else
+        body = {
+          "id"    => @message.id,
+          "input" => "errors",
+          "value" => {
+            database_name => body,
+          },
+        }
+        all_dests = []
+        descendants.each do |name, dests|
+          all_dests += dests
+        end
+        all_dests.each do |dest|
+          if @dispatcher
+            @dispatcher.dispatch(body, dest)
+          else
+            message = raw_message.merge("statusCode" => status_code,
+                                        "body" => body,)
+            forward(message, "to" => dest, "type" => "dispatcher")
+          end
+        end
       end
     end
 

  Modified: lib/droonga/plugin/distributor/crud.rb (+13 -0)
===================================================================
--- lib/droonga/plugin/distributor/crud.rb    2014-01-27 17:20:28 +0900 (00b838d)
+++ lib/droonga/plugin/distributor/crud.rb    2014-01-27 17:15:50 +0900 (6ba9e19)
@@ -44,6 +44,7 @@ module Droonga
     def scatterer(message, key)
       scatterer = super
       scatterer["outputs"] << "success"
+      scatterer["outputs"] << "errors"
       scatterer
     end
 
@@ -56,6 +57,14 @@ module Droonga
       }
       reducer["inputs"] << "success"
       reducer["outputs"] << "success_reduced"
+      reducer["body"]["errors"] = {
+        "errors_reduced" => {
+          "type" => "sum",
+          "limit" => -1,
+        },
+      }
+      reducer["inputs"] << "errors"
+      reducer["outputs"] << "errors_reduced"
       reducer
     end
 
@@ -65,6 +74,10 @@ module Droonga
         "output" => "success",
       }
       gatherer["inputs"] << "success_reduced"
+      gatherer["body"]["errors_reduced"] = {
+        "output" => "errors",
+      }
+      gatherer["inputs"] << "errors_reduced"
       gatherer
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



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