Class: Hasta::S3DataSink
- Inherits:
-
Object
- Object
- Hasta::S3DataSink
- Defined in:
- lib/hasta/s3_data_sink.rb
Overview
Data sink for writing data to S3 storage
Instance Attribute Summary collapse
-
#s3_uri ⇒ Object
readonly
Returns the value of attribute s3_uri.
Instance Method Summary collapse
- #<<(line) ⇒ Object
- #close ⇒ Object
- #data_source ⇒ Object
-
#initialize(s3_uri, combined_storage = Hasta.combined_storage) ⇒ S3DataSink
constructor
A new instance of S3DataSink.
- #to_s ⇒ Object
Constructor Details
#initialize(s3_uri, combined_storage = Hasta.combined_storage) ⇒ S3DataSink
Returns a new instance of S3DataSink.
10 11 12 13 |
# File 'lib/hasta/s3_data_sink.rb', line 10 def initialize(s3_uri, combined_storage = Hasta.combined_storage) @s3_uri = s3_uri @combined_storage = combined_storage end |
Instance Attribute Details
#s3_uri ⇒ Object (readonly)
Returns the value of attribute s3_uri.
8 9 10 |
# File 'lib/hasta/s3_data_sink.rb', line 8 def s3_uri @s3_uri end |
Instance Method Details
#<<(line) ⇒ Object
15 16 17 |
# File 'lib/hasta/s3_data_sink.rb', line 15 def <<(line) lines << Hasta.tab_separated_line(line) end |
#close ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/hasta/s3_data_sink.rb', line 19 def close storage_uri = combined_storage.write(s3_uri, contents) Hasta.logger.debug( "Wrote #{lines.count} lines to uri: #{storage_uri} (#{LocalFilePath.for(storage_uri)})" ) self end |
#data_source ⇒ Object
28 29 30 |
# File 'lib/hasta/s3_data_sink.rb', line 28 def data_source S3DataSource.new(s3_uri, combined_storage) end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/hasta/s3_data_sink.rb', line 32 def to_s "#<#{self.class.name}:#{s3_uri}>" end |