Class: LogStash::Outputs::S3::TemporaryFileFactory::IOWrappedGzip

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/logstash/outputs/s3/temporary_file_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_io) ⇒ IOWrappedGzip

Returns a new instance of IOWrappedGzip.



98
99
100
101
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 98

def initialize(file_io)
  @file_io = file_io
  @gzip_writer = Zlib::GzipWriter.new(file_io)
end

Instance Attribute Details

#file_ioObject (readonly)

Returns the value of attribute file_io.



96
97
98
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 96

def file_io
  @file_io
end

#gzip_writerObject (readonly)

Returns the value of attribute gzip_writer.



96
97
98
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 96

def gzip_writer
  @gzip_writer
end

Instance Method Details

#fsyncObject



119
120
121
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 119

def fsync
  @gzip_writer.to_io.fsync
end

#pathObject



103
104
105
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 103

def path
  @gzip_writer.to_io.path
end

#sizeObject



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/logstash/outputs/s3/temporary_file_factory.rb', line 107

def size
  # to get the current file size
  if @gzip_writer.pos == 0
    # Ensure a zero file size is returned when nothing has
    # yet been written to the gzip file.
    0
  else
    @gzip_writer.flush
    @gzip_writer.to_io.size
  end
end