Class: LogStash::Outputs::OSS::FileGenerator
- Inherits:
-
Object
- Object
- LogStash::Outputs::OSS::FileGenerator
- Defined in:
- lib/logstash/outputs/oss/file_generator.rb
Defined Under Namespace
Modules: SecureRandom
Constant Summary collapse
- FILE_MODE =
"a"- STRFTIME =
"%Y-%m-%dT%H.%M"
Instance Attribute Summary collapse
-
#current_file ⇒ Object
Returns the value of attribute current_file.
-
#encoding ⇒ Object
Returns the value of attribute encoding.
-
#index ⇒ Object
Returns the value of attribute index.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#temporary_directory ⇒ Object
Returns the value of attribute temporary_directory.
Instance Method Summary collapse
- #extension ⇒ Object
- #gzip? ⇒ Boolean
-
#initialize(prefix, encoding, temporary_directory) ⇒ FileGenerator
constructor
‘prefix`/logstash.oss.random-uuid.%Y-%m-%dT%H%Y-%m-%dT%H.%M.part-#index.#extension.
- #rotate ⇒ Object
- #with_lock ⇒ Object
Constructor Details
#initialize(prefix, encoding, temporary_directory) ⇒ FileGenerator
‘prefix`/logstash.oss.random-uuid.LogStash::Outputs::OSS::FileGenerator.%Y-%m-%dT%H%Y-%m-%dT%H.%M.part-#index.#extension
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 17 def initialize(prefix, encoding, temporary_directory) @index = 0 @prefix = prefix # gzip or plain @encoding = encoding # temporary directory to save temporary file before upload to OSS @temporary_directory = temporary_directory @lock = Mutex.new rotate end |
Instance Attribute Details
#current_file ⇒ Object
Returns the value of attribute current_file.
14 15 16 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 14 def current_file @current_file end |
#encoding ⇒ Object
Returns the value of attribute encoding.
14 15 16 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 14 def encoding @encoding end |
#index ⇒ Object
Returns the value of attribute index.
14 15 16 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 14 def index @index end |
#prefix ⇒ Object
Returns the value of attribute prefix.
14 15 16 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 14 def prefix @prefix end |
#temporary_directory ⇒ Object
Returns the value of attribute temporary_directory.
14 15 16 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 14 def temporary_directory @temporary_directory end |
Instance Method Details
#extension ⇒ Object
42 43 44 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 42 def extension @encoding == "gzip" ? "gz" : "data" end |
#gzip? ⇒ Boolean
46 47 48 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 46 def gzip? @encoding == "gzip" end |
#rotate ⇒ Object
30 31 32 33 34 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 30 def rotate @current_file = create_file @index += 1 @current_file end |
#with_lock ⇒ Object
36 37 38 39 40 |
# File 'lib/logstash/outputs/oss/file_generator.rb', line 36 def with_lock @lock.synchronize do yield self end end |