Class: DbBlaster::S3Publisher
- Inherits:
-
BasePublisher
- Object
- BasePublisher
- DbBlaster::S3Publisher
- Defined in:
- lib/db_blaster/s3_publisher.rb
Overview
Pushes records to S3
Instance Attribute Summary
Attributes inherited from BasePublisher
#batch_start_time, #records, #source_table
Instance Method Summary collapse
- #client ⇒ Object
- #content ⇒ Object
- #meta ⇒ Object
- #meta_records ⇒ Object
- #publish ⇒ Object
- #tagging ⇒ Object
- #tags_hash ⇒ Object
Methods inherited from BasePublisher
Constructor Details
This class inherits a constructor from DbBlaster::BasePublisher
Instance Method Details
#client ⇒ Object
40 41 42 43 44 |
# File 'lib/db_blaster/s3_publisher.rb', line 40 def client @client ||= Aws::S3::Client.new(region: DbBlaster.configuration.aws_region, credentials: Aws::Credentials.new(DbBlaster.configuration.aws_access_key, DbBlaster.configuration.aws_access_secret)) end |
#content ⇒ Object
16 17 18 19 20 21 |
# File 'lib/db_blaster/s3_publisher.rb', line 16 def content return if DbBlaster.configuration. == Configuration::INLINE_S3_META_FORMAT { meta: , records: records } end |
#meta ⇒ Object
32 33 34 |
# File 'lib/db_blaster/s3_publisher.rb', line 32 def @meta ||= (DbBlaster.configuration..presence || {}).merge(source_table: source_table.name) end |
#meta_records ⇒ Object
36 37 38 |
# File 'lib/db_blaster/s3_publisher.rb', line 36 def records.collect { |record| record.merge() } end |
#publish ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/db_blaster/s3_publisher.rb', line 8 def publish client.put_object(bucket: DbBlaster.configuration.s3_bucket, key: S3KeyBuilder.build(source_table_name: source_table.name, batch_start_time: batch_start_time), tagging: tagging, body: content.to_json) end |
#tagging ⇒ Object
23 24 25 |
# File 'lib/db_blaster/s3_publisher.rb', line 23 def tagging URI.encode_www_form() end |
#tags_hash ⇒ Object
27 28 29 30 |
# File 'lib/db_blaster/s3_publisher.rb', line 27 def @tags_hash ||= { source_table: source_table.name } .merge(DbBlaster.configuration..presence || {}) end |