Class: LogStash::Outputs::Swift::TimeRotationPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/swift/time_rotation_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time_file) ⇒ TimeRotationPolicy

Returns a new instance of TimeRotationPolicy.



8
9
10
11
12
13
14
# File 'lib/logstash/outputs/swift/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_fileObject (readonly)

Returns the value of attribute time_file.



6
7
8
# File 'lib/logstash/outputs/swift/time_rotation_policy.rb', line 6

def time_file
  @time_file
end

Instance Method Details

#needs_periodic?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/logstash/outputs/swift/time_rotation_policy.rb', line 20

def needs_periodic?
  true
end

#rotate?(file) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/logstash/outputs/swift/time_rotation_policy.rb', line 16

def rotate?(file)
  file.size > 0 && (Time.now - file.ctime) >= time_file
end