Class: Fluent::GcloudStorageOutput
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::GcloudStorageOutput
- Defined in:
- lib/fluent/plugin/out_gcloud_storage.rb
Constant Summary collapse
- CHUNK_ID_PLACE_HOLDER =
'${chunk_id}'- DEFAULT_TIME_SLICE_FORMAT =
'%Y%m%d'
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#format(tag, time, record) ⇒ Object
def shutdown; super; end.
-
#initialize ⇒ GcloudStorageOutput
constructor
A new instance of GcloudStorageOutput.
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ GcloudStorageOutput
Returns a new instance of GcloudStorageOutput.
15 16 17 18 19 |
# File 'lib/fluent/plugin/out_gcloud_storage.rb', line 15 def initialize super require 'gcloud' end |
Instance Method Details
#configure(conf) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fluent/plugin/out_gcloud_storage.rb', line 21 def configure(conf) predict_time_slice_format!(conf) super ensure_gcloud_arguments! ensure_proper_path! ensure_buffer_type! setup_formatter(conf) end |
#format(tag, time, record) ⇒ Object
def shutdown; super; end
43 44 45 |
# File 'lib/fluent/plugin/out_gcloud_storage.rb', line 43 def format(tag, time, record) @formatter.format(tag, time, record) end |
#start ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fluent/plugin/out_gcloud_storage.rb', line 32 def start super @gs_bucket = Gcloud .new(@project, @key) .storage .bucket(@bucket) end |
#write(chunk) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fluent/plugin/out_gcloud_storage.rb', line 47 def write(chunk) local_path = chunk.path remote_path = generate_path(chunk) log.debug('Writting chunk(%s) from: %s to: %s' % [chunk.key, local_path, remote_path]) before = Time.now.to_f @gs_bucket.create_file(local_path, remote_path) log.debug('Chunk(%s) upload was done in: %.2fs' % [chunk.key, (Time.now.to_f - before)]) end |