Class: LogStash::Outputs::S3::TimeRotationPolicy
- Inherits:
-
Object
- Object
- LogStash::Outputs::S3::TimeRotationPolicy
- Defined in:
- lib/logstash/outputs/s3/time_rotation_policy.rb
Instance Attribute Summary collapse
-
#time_file ⇒ Object
readonly
Returns the value of attribute time_file.
Instance Method Summary collapse
-
#initialize(time_file) ⇒ TimeRotationPolicy
constructor
A new instance of TimeRotationPolicy.
- #needs_periodic? ⇒ Boolean
- #rotate?(file) ⇒ Boolean
Constructor Details
#initialize(time_file) ⇒ TimeRotationPolicy
Returns a new instance of TimeRotationPolicy.
8 9 10 11 12 13 14 |
# File 'lib/logstash/outputs/s3/time_rotation_policy.rb', line 8 def initialize(time_file) if time_file <= 0 raise LogStash::ConfigurationError, "`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.
6 7 8 |
# File 'lib/logstash/outputs/s3/time_rotation_policy.rb', line 6 def time_file @time_file end |
Instance Method Details
#needs_periodic? ⇒ Boolean
20 21 22 |
# File 'lib/logstash/outputs/s3/time_rotation_policy.rb', line 20 def needs_periodic? true end |
#rotate?(file) ⇒ Boolean
16 17 18 |
# File 'lib/logstash/outputs/s3/time_rotation_policy.rb', line 16 def rotate?(file) file.size > 0 && (Time.now - file.ctime) >= time_file end |