lib/deimos/kafka_topic_info.rb in deimos-ruby-1.24.1 vs lib/deimos/kafka_topic_info.rb in deimos-ruby-1.24.2

- old
+ new

@@ -4,10 +4,15 @@ # Record that keeps track of which topics are being worked on by DbProducers. class KafkaTopicInfo < ActiveRecord::Base self.table_name = 'kafka_topic_info' class << self + + def quote_time(time) + time.respond_to?(:to_fs) ? time.to_fs(:db) : time.to_s(:db) + end + # Lock a topic for the given ID. Returns whether the lock was successful. # @param topic [String] # @param lock_id [String] # @return [Boolean] def lock(topic, lock_id) @@ -20,12 +25,12 @@ # Lock the record qtopic = self.connection.quote(topic) qlock_id = self.connection.quote(lock_id) qtable = self.connection.quote_table_name('kafka_topic_info') - qnow = self.connection.quote(Time.zone.now.to_s(:db)) + qnow = self.connection.quote(quote_time(Time.zone.now)) qfalse = self.connection.quoted_false - qtime = self.connection.quote(1.minute.ago.to_s(:db)) + qtime = self.connection.quote(quote_time(1.minute.ago)) # If a record is marked as error and less than 1 minute old, # we don't want to pick it up even if not currently locked because # we worry we'll run into the same problem again. # Once it's more than 1 minute old, we figure it's OK to try again