[Groonga-commit] droonga/droonga-engine at 8bcbfde [master] Don't overwrite last processed message timestamp with older timestamp

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 23 13:32:40 JST 2015


YUKI Hiroshi	2015-04-23 13:32:40 +0900 (Thu, 23 Apr 2015)

  New Revision: 8bcbfdeaa2ca13eba72d416f29fe58ad59a71e27
  https://github.com/droonga/droonga-engine/commit/8bcbfdeaa2ca13eba72d416f29fe58ad59a71e27

  Message:
    Don't overwrite last processed message timestamp with older timestamp

  Modified files:
    lib/droonga/engine.rb

  Modified: lib/droonga/engine.rb (+14 -2)
===================================================================
--- lib/droonga/engine.rb    2015-04-23 13:32:04 +0900 (d0c4b86)
+++ lib/droonga/engine.rb    2015-04-23 13:32:40 +0900 (dfdde72)
@@ -109,7 +109,13 @@ module Droonga
     end
 
     def process(message)
-      @last_processed_message_timestamp = message["date"]
+      if message.include?("date")
+        date = Time.parse(message["date"])
+        if @last_processed_message_timestamp.nil? or
+             @last_processed_message_timestamp < date
+          @last_processed_message_timestamp = date
+        end
+      end
       @dispatcher.process_message(message)
     end
 
@@ -128,11 +134,17 @@ module Droonga
       Dispatcher.new(@state, @cluster, @catalog)
     end
 
+    MICRO_SECONDS_DECIMAL_PLACE = 6
+
     def save_last_processed_message_timestamp
       logger.trace("save_last_processed_message_timestamp: start")
       if @last_processed_message_timestamp
+        timestamp = @last_processed_message_timestamp
+        timestamp = timestamp.utc.iso8601(MICRO_SECONDS_DECIMAL_PLACE)
         serf = Serf.new(@name)
-        serf.last_processed_message_timestamp = @last_processed_message_timestamp
+        serf.last_processed_message_timestamp = timestamp
+        logger.info("saved last processed message timestamp",
+                    :timestamp => timestamp)
       end
       logger.trace("save_last_processed_message_timestamp: done")
     end
-------------- next part --------------
HTML����������������������������...
Descargar 



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