Class: LogStash::Outputs::Qingstor::RotationPolicy::Time

Inherits:
Policy
  • Object
show all
Defined in:
lib/logstash/outputs/qingstor/rotation_policy.rb

Instance Method Summary collapse

Methods inherited from Policy

#name, #needs_periodic?, #positive_check

Constructor Details

#initialize(_, file_time) ⇒ Time

Returns a new instance of Time.



27
28
29
30
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 27

def initialize(_, file_time)
  @file_time = file_time
  positive_check(@file_time)
end

Instance Method Details

#rotate?(file) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 32

def rotate?(file)
  !file.empty? && (::Time.now - file.ctime) >= @file_time
end

#to_sObject



36
37
38
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 36

def to_s
  { :policy => name, :file_time => @file_time }.to_s
end