Class: Fluent::RackspaceCloudFilesOutput
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::RackspaceCloudFilesOutput
- Includes:
- Mixin::ConfigPlaceholders, SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_rackspace_cloud_files.rb
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ RackspaceCloudFilesOutput
constructor
A new instance of RackspaceCloudFilesOutput.
- #placeholders ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ RackspaceCloudFilesOutput
Returns a new instance of RackspaceCloudFilesOutput.
7 8 9 10 11 12 13 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 7 def initialize super require 'fog' require 'zlib' require 'time' require 'tempfile' end |
Instance Method Details
#configure(conf) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 48 def configure(conf) super @ext, @mime_type = storage_method @timef = TimeFormatter.new(@time_format, @localtime) @path_slicer = time_slicer end |
#format(tag, time, record) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 67 def format(tag, time, record) time_str = @timef.format(time) if @include_time_key || !@format_json # copied from each mixin because current TimeSlicedOutput can't support # mixins. record[@tag_key] = tag if @include_tag_key record[@time_key] = time_str if @include_time_key if @format_json Yajl.dump(record) + "\n" else "#{time_str}\t#{tag}\t#{Yajl.dump(record)}\n" end end |
#placeholders ⇒ Object
44 45 46 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 44 def placeholders [:percent] end |
#start ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 55 def start super Excon.defaults[:ssl_verify_peer] = @ssl_verify @storage = Fog::Storage.new provider: 'Rackspace', rackspace_auth_url: @rackspace_auth_url, rackspace_username: @rackspace_username, rackspace_api_key: @rackspace_api_key, rackspace_region: @rackspace_region check_container end |
#write(chunk) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fluent/plugin/out_rackspace_cloud_files.rb', line 82 def write(chunk) i = 0 previous_path = nil begin path = @path_slicer.call(@path) values_for_swift_object_key = { 'path' => path, 'time_slice' => chunk.key, 'file_extension' => @ext, 'index' => i } swift_path = @object_key_format.gsub(%r(%{[^}]+})) do |expr| values_for_swift_object_key[expr[2...expr.size - 1]] end if (i > 0) && (swift_path == previous_path) fail 'duplicated path is generated. use %{index} in '\ "object_key_format: path = #{swift_path}" end i += 1 previous_path = swift_path end while check_object_exists(@rackspace_container, swift_path) write_temp_file(chunk, swift_path) end |