class DbBlaster::PublishSourceTable
Given a `source_table` providing the table name, finds rows in `batch_size` chunks that are published to SNS
Attributes
batch_start_time[R]
source_table[R]
Public Class Methods
execute(source_table:, batch_start_time:)
click to toggle source
# File lib/db_blaster/publish_source_table.rb, line 14 def self.execute(source_table:, batch_start_time:) new(source_table, batch_start_time).execute end
new(source_table, batch_start_time)
click to toggle source
# File lib/db_blaster/publish_source_table.rb, line 9 def initialize(source_table, batch_start_time) @source_table = source_table @batch_start_time = batch_start_time end
Public Instance Methods
execute()
click to toggle source
# File lib/db_blaster/publish_source_table.rb, line 18 def execute DbBlaster.configuration.verify! # will raise error if required configurations are not set # pessimistically lock row for the duration source_table.with_lock do Finder.find(source_table) do |records| BasePublisher.publish(source_table: source_table, records: records, batch_start_time: batch_start_time) source_table.update(last_published_updated_at: records.last['updated_at'], last_published_id: records.last['id']) end end self end