Class: LogStash::Outputs::LogstashAzureBlobOutput::TemporaryFileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/blob/temporary_file_factory.rb

Overview

a sub class of LogstashAzureBlobOutput creates the temporary files to write and later upload

Defined Under Namespace

Classes: IOWrappedGzip

Constant Summary collapse

FILE_MODE =
'a'.freeze
GZIP_ENCODING =
'gzip'.freeze
GZIP_EXTENSION =
'txt.gz'.freeze
TXT_EXTENSION =
'txt'.freeze
STRFTIME =
'%Y-%m-%dT%H.%M'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, tags, encoding, temporary_directory) ⇒ TemporaryFileFactory

initialize the class



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 22

def initialize(prefix, tags, encoding, temporary_directory)
  @counter = 0
  @prefix = prefix

  @tags = tags
  @encoding = encoding
  @temporary_directory = temporary_directory
  @lock = Mutex.new

  rotate!
end

Instance Attribute Details

#counterObject

Returns the value of attribute counter.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def counter
  @counter
end

#currentObject

Returns the value of attribute current.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def current
  @current
end

#encodingObject

Returns the value of attribute encoding.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def encoding
  @encoding
end

#prefixObject

Returns the value of attribute prefix.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def prefix
  @prefix
end

#tagsObject

Returns the value of attribute tags.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def tags
  @tags
end

#temporary_directoryObject

Returns the value of attribute temporary_directory.



19
20
21
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 19

def temporary_directory
  @temporary_directory
end

Instance Method Details

#rotate!Object

do the rotation



35
36
37
38
39
40
41
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 35

def rotate!
  @lock.synchronize do
    @current = new_file
    increment_counter
    @current
  end
end