[Groonga-commit] droonga/fluent-plugin-droonga at b1dd087 [master] Return error response if the dataset is missing

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 26 14:20:58 JST 2013


YUKI Hiroshi	2013-12-26 14:20:58 +0900 (Thu, 26 Dec 2013)

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

  Message:
    Return error response if the dataset is missing

  Modified files:
    lib/droonga/dispatcher.rb

  Modified: lib/droonga/dispatcher.rb (+22 -0)
===================================================================
--- lib/droonga/dispatcher.rb    2013-12-26 13:57:39 +0900 (1b8eb80)
+++ lib/droonga/dispatcher.rb    2013-12-26 14:20:58 +0900 (9c6bf95)
@@ -26,11 +26,21 @@ require "droonga/collector"
 require "droonga/farm"
 require "droonga/session"
 require "droonga/replier"
+require "droonga/responsible_error"
 
 module Droonga
   class Dispatcher
     attr_reader :name
 
+    class InvalidRequest < ResponsibleClientError
+    end
+
+    class MissingDataset < InvalidRequest
+      def initialize
+        super("\"dataset\" must be specified.")
+      end
+    end
+
     def initialize(options)
       @options = options
       @name = @options[:name]
@@ -73,6 +83,7 @@ module Droonga
       if message["type"] == "dispatcher"
         process_internal_message(message["body"])
       else
+        return unless assert_have_dataset
         process_input_message(message)
       end
     end
@@ -180,6 +191,17 @@ module Droonga
       @distributor.process(adapted_message["type"], adapted_message)
     end
 
+    def assert_have_dataset
+      unles****@messa*****?("dataset")
+        error = MissingDataset.new
+        response = @output_adapter.adapt(@message.merge("statusCode" => error.status_code,
+                                                        "body" => error.response_body))
+        @replier.reply(response)
+        return false
+      end
+      true
+    end
+
     def log_tag
       "[#{Process.ppid}][#{Process.pid}] dispatcher"
     end
-------------- next part --------------
HTML����������������������������...
Download 



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