[Groonga-commit] groonga/fluent-plugin-droonga at 013de48 [master] Store the incoming message to the queue as is.

Back to archive index

Daijiro MORI null+****@clear*****
Wed Apr 24 15:46:09 JST 2013


Daijiro MORI	2013-04-24 15:46:09 +0900 (Wed, 24 Apr 2013)

  New Revision: 013de48b31e4c2ab81b48c3f86ef83bc03c2131f
  https://github.com/groonga/fluent-plugin-droonga/commit/013de48b31e4c2ab81b48c3f86ef83bc03c2131f

  Message:
    Store the incoming message to the queue as is.

  Modified files:
    lib/droonga/worker.rb

  Modified: lib/droonga/worker.rb (+18 -6)
===================================================================
--- lib/droonga/worker.rb    2013-04-24 12:08:40 +0900 (380f737)
+++ lib/droonga/worker.rb    2013-04-24 15:46:09 +0900 (c0d2f2d)
@@ -59,7 +59,10 @@ module Droonga
 
     def dispatch(*message)
       parse_message(message)
-      post(envelope["body"], envelope["type"], *envelope["arguments"])
+      post_or_push(message,
+                   envelope["body"],
+                   envelope["type"],
+                   envelope["arguments"])
     end
 
     def add_handler(name)
@@ -72,6 +75,11 @@ module Droonga
     end
 
     def post(body, destination=nil, *arguments)
+      post_or_push(nil, body, destination, arguments)
+    end
+
+    private
+    def post_or_push(message, body, destination, arguments)
       route = nil
       unless destination
         route = envelope["via"].pop
@@ -101,14 +109,19 @@ module Droonga
           if route || @pool.empty? || synchronous
             handler.handle(command, body, *arguments)
           else
-            push_message
+            unless message
+              envelope["body"] = body
+              envelope["type"] = command
+              envelope["arguments"] = arguments
+              message = ['', Time.now.to_f, envelope]
+            end
+            push_message(message)
           end
         end
       end
       add_route(route) if route
     end
 
-    private
     def output(body, receiver, is_reply=false)
       output = get_output(receiver)
       return unless output
@@ -127,7 +140,6 @@ module Droonga
     end
 
     def parse_message(message)
-      @message = message
       tag, time, record = message
       prefix, type, *arguments = tag.split(/\./)
       if type.nil? || type.empty? || type == 'message'
@@ -142,8 +154,8 @@ module Droonga
       envelope["via"] ||= []
     end
 
-    def push_message
-      packed_message =****@messa*****_msgpack
+    def push_message(message)
+      packed_message = message.to_msgpack
       queue = @context[@queue_name]
       queue.push do |record|
         record.message = packed_message
-------------- next part --------------
HTML����������������������������...
Download 



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