Class: LogStash::Outputs::LogstashAzureBlobOutput::TimeRotationPolicy

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_fileObject (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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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