Class: LogStash::Outputs::LogstashAzureBlobOutput::TimeRotationPolicy
- Inherits:
-
Object
- Object
- LogStash::Outputs::LogstashAzureBlobOutput::TimeRotationPolicy
- Defined in:
- lib/logstash/outputs/blob/time_rotation_policy.rb
Overview
a sub class of LogstashAzureBlobOutput
sets the policy for time rotation
Instance Attribute Summary collapse
-
#time_file ⇒ Object
readonly
Returns the value of attribute time_file.
Instance Method Summary collapse
-
#initialize(time_file) ⇒ TimeRotationPolicy
constructor
initialize the class and validate the time file.
-
#needs_periodic? ⇒ Boolean
boolean method.
-
#rotate?(file) ⇒ Boolean
rotates based on time policy.
Constructor Details
#initialize(time_file) ⇒ TimeRotationPolicy
initialize the class and validate the time file
9 10 11 12 13 14 15 |
# File 'lib/logstash/outputs/blob/time_rotation_policy.rb', line 9 def initialize(time_file) if time_file <= 0 raise LogStash::ConfigurationError.new('`time_file` need to be greather than 0') end @time_file = time_file * 60 end |
Instance Attribute Details
#time_file ⇒ Object (readonly)
Returns the value of attribute time_file.
7 8 9 |
# File 'lib/logstash/outputs/blob/time_rotation_policy.rb', line 7 def time_file @time_file end |
Instance Method Details
#needs_periodic? ⇒ Boolean
boolean method
23 24 25 |
# File 'lib/logstash/outputs/blob/time_rotation_policy.rb', line 23 def needs_periodic? true end |
#rotate?(file) ⇒ Boolean
rotates based on time policy
18 19 20 |
# File 'lib/logstash/outputs/blob/time_rotation_policy.rb', line 18 def rotate?(file) !file.empty? && (Time.now - file.ctime) >= time_file end |