Navigation Menu

Skip to content

Commit

Permalink
Remove codes to process effective message timestamp by the receiver side
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 7, 2015
1 parent fe492f8 commit 6fcc5b4
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions lib/droonga/engine.rb
Expand Up @@ -15,8 +15,8 @@
# 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 "fileutils"

require "droonga/engine/version"
require "droonga/loggable"
require "droonga/deferrable"
Expand Down Expand Up @@ -95,7 +95,6 @@ def stop_immediately
end

def process(message)
return unless effective_message?(message)
@last_processed_message_timestamp = message["date"]
@dispatcher.process_message(message)
end
Expand Down Expand Up @@ -123,40 +122,6 @@ def save_last_processed_message_timestamp
logger.trace("output_last_processed_message_timestamp: done")
end

def effective_message?(message)
effective_timestamp = effective_message_timestamp
return true if effective_timestamp.nil?
return true unless message["date"]

begin
message_timestamp = Time.parse(message["date"])
rescue ArgumentError
logger.error("failed to parse the \"date\" field of a message",
:message => message)
return false
end

logger.trace("checking effective_message_timestamp (#{effective_timestamp}) vs message_timestamp(#{message_timestamp})")
return false if effective_timestamp >= message_timestamp

logger.info("New message at #{message_timestamp} (newer than #{effective_timestamp}) is detected. The effective timestamp is now cleared.")
logger.trace("deleting obsolete effective_message_timestamp: start")
@node_metadata.delete(:effective_message_timestamp)
logger.trace("deleting obsolete effective_message_timestamp: done")
true
end

def effective_message_timestamp
timestamp = @node_metadata.get(:effective_message_timestamp)
return nil unless timestamp

begin
Time.parse(timestamp)
rescue ArgumentError
nil
end
end

def log_tag
"engine"
end
Expand Down

0 comments on commit 6fcc5b4

Please sign in to comment.