lib/deimos/utils/db_poller/state_based.rb in deimos-ruby-1.22.2 vs lib/deimos/utils/db_poller/state_based.rb in deimos-ruby-1.22.3

- old
+ new

@@ -10,23 +10,26 @@ # Send messages for updated data. # @return [void] def process_updates Deimos.config.logger.info("Polling #{log_identifier}") status = PollStatus.new(0, 0, 0) + first_batch = true # poll_query gets all the relevant data from the database, as defined # by the producer itself. loop do Deimos.config.logger.debug("Polling #{log_identifier}, batch #{status.current_batch}") batch = fetch_results.to_a - if batch.empty? - @info.touch(:last_sent) - break - end + break if batch.empty? + first_batch = false success = process_batch_with_span(batch, status) finalize_batch(batch, success) end + + # If there were no results at all, we update last_sent so that we still get a wait + # before the next poll. + @info.touch(:last_sent) if first_batch Deimos.config.logger.info("Poll #{log_identifier} complete (#{status.report}") end # @return [ActiveRecord::Relation] def fetch_results