[Groonga-commit] groonga/groonga-query-log at 27eb3ee [master] replayer: support reconnect on error

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Sep 18 09:57:08 JST 2013


Kouhei Sutou	2013-09-18 09:57:08 +0900 (Wed, 18 Sep 2013)

  New Revision: 27eb3ee487e9450663646162113fc63b8ad9760e
  https://github.com/groonga/groonga-query-log/commit/27eb3ee487e9450663646162113fc63b8ad9760e

  Message:
    replayer: support reconnect on error

  Modified files:
    lib/groonga/query-log/replayer.rb

  Modified: lib/groonga/query-log/replayer.rb (+14 -3)
===================================================================
--- lib/groonga/query-log/replayer.rb    2013-09-18 09:43:57 +0900 (cae421b)
+++ lib/groonga/query-log/replayer.rb    2013-09-18 09:57:08 +0900 (e7bec3f)
@@ -16,6 +16,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+require "time"
 require "thread"
 
 require "groonga/client"
@@ -62,7 +63,9 @@ module Groonga
       def run_consumers
         @options.n_clients.times.collect do
           Thread.new do
-            run_consumer
+            loop do
+              break if run_consumer
+            end
           end
         end
       end
@@ -73,9 +76,17 @@ module Groonga
             id, statistic =****@queue*****
             if id.nil?
               @responses.push(nil)
-              break
+              return true
+            end
+            begin
+              replay_command(client, id, statistic.command)
+            rescue Groonga::Client::Connection::Error
+              # TODO: add error log mechanism
+              $stderr.puts(Time.now.iso8601)
+              $stderr.puts($!.raw_error.message)
+              $stderr.puts($!.raw_error.backtrace)
+              return false
             end
-            replay_command(client, id, statistic.command)
           end
         end
       end
-------------- next part --------------
HTML����������������������������...
Download 



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