lib/alephant/sequencer/sequencer.rb in alephant-sequencer-1.0.0 vs lib/alephant/sequencer/sequencer.rb in alephant-sequencer-1.1.0

- old
+ new

@@ -1,7 +1,6 @@ require 'jsonpath' - require 'alephant/logger' module Alephant module Sequencer class Sequencer @@ -13,10 +12,11 @@ @keep_all = keep_all @exists = exists? @jsonpath = sequence_path @ident = id + logger.info("Sequencer#initialize: table: #{sequence_table}, jsonpath: #{sequence_path}, id: #{id}") end def sequential?(msg) (get_last_seen || 0) < Sequencer.sequence_id_from(msg, jsonpath) end @@ -27,16 +27,16 @@ def validate(msg, &block) last_seen_id = get_last_seen sequential = ((last_seen_id || 0) < Sequencer.sequence_id_from(msg, jsonpath)) - block.call(msg) if (sequential || keep_all) + block.call if (sequential || keep_all) if sequential set_last_seen(msg, last_seen_id) else - logger.info("Sequencer#sequence nonsequential message for #{ident}") + logger.info("Sequencer#sequence nonsequential message for #{ident} (last_seen_id: #{last_seen_id})") end end def delete! logger.info("Sequencer#delete!: #{ident}") @@ -49,10 +49,10 @@ end def set_last_seen(msg, last_seen_check = nil) seen_id = Sequencer.sequence_id_from(msg, jsonpath) - @sequence_table.set_sequence_for( + @sequence_table.update_sequence_id( ident, seen_id, (exists? ? last_seen_check : nil) ) end