Navigation Menu

Skip to content

Commit

Permalink
Don't overwrite last processed message timestamp with older timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 23, 2015
1 parent 6ec30d9 commit 8bcbfde
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/droonga/engine.rb
Expand Up @@ -109,7 +109,13 @@ def refresh_self_reference
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

Expand All @@ -128,11 +134,17 @@ def create_dispatcher
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
Expand Down

0 comments on commit 8bcbfde

Please sign in to comment.