Class: Terastream::Output::S3
- Inherits:
-
Object
- Object
- Terastream::Output::S3
- Defined in:
- lib/terastream/middleware/output/s3.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #<<(record) ⇒ Object
- #complete! ⇒ Object
-
#initialize(options = {}) ⇒ S3
constructor
A new instance of S3.
Constructor Details
#initialize(options = {}) ⇒ S3
Returns a new instance of S3.
9 10 11 12 13 14 |
# File 'lib/terastream/middleware/output/s3.rb', line 9 def initialize( = {}) = @temp = "" @connection = Aws::S3::Client.new(region: region) @records = [] end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/terastream/middleware/output/s3.rb', line 7 def end |
Instance Method Details
#<<(record) ⇒ Object
16 17 18 |
# File 'lib/terastream/middleware/output/s3.rb', line 16 def <<(record) @temp += record.is_a?(Hash) || record.is_a?(String) ? as_json(record) : as_csv(record) end |
#complete! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/terastream/middleware/output/s3.rb', line 20 def complete! tries = @max_retries begin @connection.put_object( key: [:key], bucket: [:bucket], body: @temp ) rescue => e retries -= 1 retry if tries > 0 end end |