Class: DbBlaster::PublishSourceTable
- Inherits:
-
Object
- Object
- DbBlaster::PublishSourceTable
- Defined in:
- lib/db_blaster/publish_source_table.rb
Overview
Given a ‘source_table` providing the table name, finds rows in `batch_size` chunks that are published to SNS
Instance Attribute Summary collapse
-
#batch_start_time ⇒ Object
readonly
Returns the value of attribute batch_start_time.
-
#source_table ⇒ Object
readonly
Returns the value of attribute source_table.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(source_table, batch_start_time) ⇒ PublishSourceTable
constructor
A new instance of PublishSourceTable.
Constructor Details
#initialize(source_table, batch_start_time) ⇒ PublishSourceTable
Returns a new instance of PublishSourceTable.
9 10 11 12 |
# 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 |
Instance Attribute Details
#batch_start_time ⇒ Object (readonly)
Returns the value of attribute batch_start_time.
7 8 9 |
# File 'lib/db_blaster/publish_source_table.rb', line 7 def batch_start_time @batch_start_time end |
#source_table ⇒ Object (readonly)
Returns the value of attribute source_table.
7 8 9 |
# File 'lib/db_blaster/publish_source_table.rb', line 7 def source_table @source_table end |
Class Method Details
.execute(source_table:, batch_start_time:) ⇒ Object
14 15 16 |
# 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 |
Instance Method Details
#execute ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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 |